"Shoaib Mir" <shoaibmir@xxxxxxxxx> writes: > Try using it with 'execute' as that might help... In current releases you need EXECUTE, else the thing will try to cache a query plan using the OID of the first instance of the temp table, and that won't work for subsequent instances. > OR: > CREATE TEMP TABLE tblname WITH (OIDS) ON COMMIT DROP AS select * from > someothertbl; ON COMMIT DROP won't help, but maybe you could have just one temp table per session, created with ON COMMIT DELETE ROWS? Or try TRUNCATE'ing the table when it already exists. This will be all better in 8.3, FWIW. regards, tom lane