By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Error: relation with OID 22938 does not exist

P: 10
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 following message:

Error: relation with OID 22938 does not exist

The query it is running is the following:

Select Into sTableName TableName From tmp_tblJoin Where ID = 1;

Nothing special about it other than "tmp_tblJoin" is defined as a temporary table.

I do understand what is happening (I think). There is a stale pointer to the previous instance of the temp table (that no longer exists) which is causing the function to blow up. My question is how to I stop it from storing the OID of the old reference.

plz help me out.........
Dec 6 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 700
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 following message:

Error: relation with OID 22938 does not exist

The query it is running is the following:

Select Into sTableName TableName From tmp_tblJoin Where ID = 1;

Nothing special about it other than "tmp_tblJoin" is defined as a temporary table.

I do understand what is happening (I think). There is a stale pointer to the previous instance of the temp table (that no longer exists) which is causing the function to blow up. My question is how to I stop it from storing the OID of the old reference.

plz help me out.........
Maybe try to define a variable a set it to temporary table name. Then execute a dynamic query using your variable as table name. Understand?
Dec 6 '07 #2

P: 10
Maybe try to define a variable a set it to temporary table name. Then execute a dynamic query using your variable as table name. Understand?
i have done according to ur suggestion....but identifier is going to be truncated.

declare

stmt text:="(i have written query here)";

begin

execute stmt;

end;

it is going to be splitting that declared query.......

whats the solution for this????
Dec 6 '07 #3

Expert 100+
P: 700
i have done according to ur suggestion....but identifier is going to be truncated.

declare

stmt text:="(i have written query here)";

begin

execute stmt;

end;

it is going to be splitting that declared query.......

whats the solution for this????

declare
table text
begin
table:='your_temp_table';
execute 'select ......from '|| table;

is that works?
Dec 6 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.