On Saturday 27 September 2003 14:31, George A.J wrote:
> hi,
>
> I am using postgresql 7.3.2. Is there any function to determine
> whether a table exists in the database.Or is there any function
> that returns the current temp schema.
> I am using a pl/pgsql function that create and drop a temporary table.
> The procedure run correctly for the first time for each database
> connection. If I run the same procedure second time in the same connection
> it produces the error
>
> "ERROR:  pg_class_aclcheck: relation 219389 not found
> WARNING:  Error occurred while executing PL/pgSQL function testFun
> WARNING:  line 20 at SQL statement "

This is because plpgsql is "compiled" and so the reference to tempTable gets 
fixed the first time it is called. In your case, the oid was 219389.

Now, the second time you call the function, the temp table gets re-created, 
gets a new OID and the old reference is no longer valid your insert line.

There are two solutions:
1. Use pltcl/plperl or some other interpreted language that doesn't compile in 
table references.
2. Build your insert statement using EXECUTE ''INSERT INTO tempTable ''...

This second passes the query string into the parser, so it works just fine for 
your example. I think some of this is covered in the manuals, you can 
certainly find plenty on it in the archives.

-- 
  Richard Huxton
  Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to