473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PGplSql: Relation 44451 does not exist

Hi,

I have a pgplsql function. It is quite short and simple.

The problem:

The following error message comes up for the SECOND time I call the it

"Relation 44451 does not exist"

In the function I create a temporary table, and at the end I drop it. There
may be problem with this ? I don't know.

So the error message does not come up for the first call.

The body of function:

declare

in_type alias for $1;

in_MemberID alias for $2;

in_SponsorID alias for $3;

vSponsorID integer;

vtSponsorID integer;

vi integer;

vMaxi integer;

vDirect integer;

vRec record;

begin

vDirect := (select count(*) as ps from comMatrixMembers cmm
where cmm.state ='A' and cmm.sponsorID = in_SponsorID);

create temp sequence Tmembers_id0_id_seq;

create temp table Tmembers (

id0_id integer default nextval('Tmembers_id0_id_seq') ,

memberID integer NOT NULL

);

vi := 0;

vSponsorID := in_SponsorID;

vMaxi := 2;

while vi <= vMaxi loop

vtSponsorID := vSponsorID;

vSponsorID := (select memberID from Tmembers where id0_id = vi);

if vSponsorID is null then

vSponsorID := vtSponsorID;

end if;

insert into Tmembers (memberID)

select cmm.memberID from
comMatrixMembers cmm

where cmm.sponsorID = vSponsorID

and cmm.state = 'A';

vMaxi := (select coalesce(max(id0_id),0) as vm from Tmembers);

vi := vi + 1;

end loop;

vi := (select (count(*) - vDirect) as ps from Tmembers);

-- check whether in_SponsorID is a sponsor of in_MemberID

vMaxi := (select count(*) as ps from Tmembers where memberID =
in_MemberID);

if in_MemberID = in_SponsorID then

vMaxi := 1;

end if;

drop sequence Tmembers_id0_id_seq;

drop table Tmembers;

if in_type = 'D' then

return vDirect;

elsif in_type ='I' then

return vi;

elsif in_type = 'A' then

return vi + vDirect;

else

return vMaxi;

end if;

end
Nov 23 '05 #1
2 2030
Kuti Attila wrote:
Hi,

I have a pgplsql function. It is quite short and simple.

The problem:

The following error message comes up for the SECOND time I call the it
"Relation 44451 does not exist"

In the function I create a temporary table, and at the end I drop it. There
may be problem with this ? I don't know.


Plpgsql is compiled, so it refers to tables via their OID. The second
time around Tmembers has a different OID and so you get your error message.

The solution is to use the EXECUTE construct when accessing the table,
or to use an interpreted language (e.g. pltcl).

HTH
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2
Hello,

read please http://www.postgresql.org/docs/faqs/FAQ.html#4.26

regards
Pavel Stehule

On Tue, 22 Jun 2004, Kuti Attila wrote:
Hi,

I have a pgplsql function. It is quite short and simple.

The problem:

The following error message comes up for the SECOND time I call the it

"Relation 44451 does not exist"

In the function I create a temporary table, and at the end I drop it. There
may be problem with this ? I don't know.

So the error message does not come up for the first call.

The body of function:

declare

in_type alias for $1;

in_MemberID alias for $2;

in_SponsorID alias for $3;

vSponsorID integer;

vtSponsorID integer;

vi integer;

vMaxi integer;

vDirect integer;

vRec record;

begin

vDirect := (select count(*) as ps from comMatrixMembers cmm
where cmm.state ='A' and cmm.sponsorID = in_SponsorID);

create temp sequence Tmembers_id0_id_seq;

create temp table Tmembers (

id0_id integer default nextval('Tmembers_id0_id_seq') ,

memberID integer NOT NULL

);

vi := 0;

vSponsorID := in_SponsorID;

vMaxi := 2;

while vi <= vMaxi loop

vtSponsorID := vSponsorID;

vSponsorID := (select memberID from Tmembers where id0_id = vi);

if vSponsorID is null then

vSponsorID := vtSponsorID;

end if;

insert into Tmembers (memberID)

select cmm.memberID from
comMatrixMembers cmm

where cmm.sponsorID = vSponsorID

and cmm.state = 'A';

vMaxi := (select coalesce(max(id0_id),0) as vm from Tmembers);

vi := vi + 1;

end loop;

vi := (select (count(*) - vDirect) as ps from Tmembers);

-- check whether in_SponsorID is a sponsor of in_MemberID

vMaxi := (select count(*) as ps from Tmembers where memberID =
in_MemberID);

if in_MemberID = in_SponsorID then

vMaxi := 1;

end if;

drop sequence Tmembers_id0_id_seq;

drop table Tmembers;

if in_type = 'D' then

return vDirect;

elsif in_type ='I' then

return vi;

elsif in_type = 'A' then

return vi + vDirect;

else

return vMaxi;

end if;

end

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Luc Martineau | last post by:
Hello, I have a question about pgplsql: Is it faster to execute a compact function (with minimal spaces and comments) than a function with many comments and many spaces? In others words,...
2
by: S.Peppe | last post by:
Hi there! I'm really new at this game, so please forgive me if my request is at all irritating. I have installed PostgreSQL onto a Debian/Linux machine, and I have just upgraded PostgreSQL via...
5
by: Christian Traber | last post by:
Hi, I'll try to switch from Oracle to postgres for some small applications. Is it possible to build functions like Oracle's nvl or decode with pgplsql? How can I make a function like nvl that...
3
by: Terrence Brannon | last post by:
I don't know what Postgres considers a relation and had no intention of creating one when piping my schema to it... I always DROP TABLE before CREATE TABLE, so here are the ERRORS emitted when...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
15
by: Hi5 | last post by:
Hi, I am designing a database for a client in which It has a client table including the followings: 1-Table Client 2-Table lookupcategory 3-Table Ctegory
7
by: Juris Krumins | last post by:
I have a problem with postgresql tables. periodicaly, I would say frequently about 5-10 time per hour i have such errors in my server log file: 2004-04-14 12:23:32 ERROR: cache lookup of...
0
by: Rob Klaus | last post by:
Hello, We are having a problem where intermittently a query will not work, returning an error: ERROR: Relation "x" does not exist It will do this for a variable period, typically not...
3
by: Shree111 | last post by:
I am having some problems understanding how the temp tables work in PG. I have a relatively lengthy function I am creating that makes frequent use of temporary tables. I am dropping and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.