X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 3D702CB5FA for ; Sat, 12 Jul 2003 08:45:45 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 30853-09 for ; Sat, 12 Jul 2003 08:45:29 +0000 (GMT) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 9E78ACB5C7 for ; Sat, 12 Jul 2003 05:45:11 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 19bG0Y-000Mmh-0X; Sat, 12 Jul 2003 09:45:30 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id A179E178D5; Sat, 12 Jul 2003 09:45:29 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id F0DE0163BE; Sat, 12 Jul 2003 09:45:28 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: "Vijay Kumar" , Subject: Re: Problem with temporary table -- Urgent Date: Sat, 12 Jul 2003 09:45:35 +0100 User-Agent: KMail/1.4.3 References: <000801c346be$cf166db0$cf01a8c0@vijay> In-Reply-To: <000801c346be$cf166db0$cf01a8c0@vijay> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200307120945.36058.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/147 X-Sequence-Number: 14261 On Thursday 10 Jul 2003 9:39 am, 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 [snip] > lString :=3D lString || '' create temporary table temp_Table( N= ame > Numeric);''; [snip] > open refc for select * from temp_Table; [snip] > psql:test18.sql:25: ERROR: Relation "temp_table" does not exist Sorry about the delay. The issue is that plpgsql is compiled, so the "open refc ... temp_Table"=20 refers to a specific entry in the system-tables. When the temp-table gets= =20 recreated it gets a new OID and so your function can't find it. Solution: 1. Don't use temp-tables 2. Use EXECUTE "..." which gets parsed when the function is run. Note that this problem applies to any table that gets dropped and restored.= I=20 try to keep my function code in the same file as the table(s) they rely on,= =20 that way I recreate both when I make changes. --=20 Richard Huxton