473,569 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 comMatrixMember s 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('Tmembe rs_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
comMatrixMember s cmm

where cmm.sponsorID = vSponsorID

and cmm.state = 'A';

vMaxi := (select coalesce(max(id 0_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 2045
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 comMatrixMember s 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('Tmembe rs_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
comMatrixMember s cmm

where cmm.sponsorID = vSponsorID

and cmm.state = 'A';

vMaxi := (select coalesce(max(id 0_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
1991
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, which one will be faster? AAAAA_function or BBBBB_function ?
2
7179
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 the apt-get update & upgrade commands. However, whenever I get into the PostgreSQL interactive terminal thus sp@vanthoff:~$ psql -U postgres SHG
5
8757
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 works for every datatype? Best regards, Christian
3
11355
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 building the database: 3:ERROR: table "country" does not exist 6:ERROR: table "customer" does not exist 11:ERROR: table "product" does not exist...
175
11265
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 think is PostgreSQL would have less USP's (Uniqe Selling Points
15
2706
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
2713
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 relation 149064743 failed 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does...
0
2575
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 lasting more than 5 minutes
3
10330
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 recreating the temp tables on each run. If I run the procedure the first time via psql it seems to run fine. If I try to immediately run it again I get the...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.