X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id 80E33CB52E for ; Sat, 12 Jul 2003 04:03:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 26762-09 for ; Sat, 12 Jul 2003 04:03:33 +0000 (GMT) Received: from megazone.bigpanda.com (unknown [66.180.233.26]) by svr1.postgresql.org (Postfix) with ESMTP id 656B4CB5E3 for ; Sat, 12 Jul 2003 01:03:13 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 17D51D736; Fri, 11 Jul 2003 21:03:32 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 0D5535C0F; Fri, 11 Jul 2003 21:03:32 -0700 (PDT) Date: Fri, 11 Jul 2003 21:03:31 -0700 (PDT) From: Stephan Szabo To: Vijay Kumar Cc: Subject: Re: Problem with temporary table -- Urgent In-Reply-To: <000801c346be$cf166db0$cf01a8c0@vijay> Message-ID: <20030711205654.U3777-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/278 X-Sequence-Number: 14392 On Thu, 10 Jul 2003, Vijay Kumar wrote: > Hi, > We are using postgresql 7.3.3, we are encountering the following problems when we used temporary tables. > > Here with i'm sending my Sample function. > > create or replace function TestTemp_refcur(refcursor) returns refcursor As ' > declare > refc alias for $1; > lString Varchar(4000); > begin > lString := '' CREATE OR REPLACE FUNCTION TESTTEMP() RETURNS varchar as '''' > > BEGIN ''; > lString := lString || '' create temporary table temp_Table( Name Numeric);''; > > lString := lString || '' insert into temp_Table values (1); ''; > > lString := lString || '' insert into temp_Table values (2);''; > > lString := lString || '' return null; end;'''' language ''''plpgsql'''';''; > > raise notice '' Notice is % '', lString; > execute lString; Okay, this create a function which would create the table and insert some stuff. But you don't actually appear to call it afaics. > open refc for select * from temp_Table; I think you may need to use open for execute here as well to make it work with temporary tables in any case. > return refc; > end; > ' language 'plpgsql'; > > begin; > select TestTemp_refcur('funcursor'); > fetch all in funcursor; > commit; > > > psql:test18.sql:25: WARNING: Error occurred while executing PL/pgSQL function t > esttemp_refcur > psql:test18.sql:25: WARNING: line 20 at open > psql:test18.sql:25: ERROR: Relation "temp_table" does not exist > psql:test18.sql:26: ERROR: current transaction is aborted, queries ignored unti > l end of transaction block