From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | "Vijay Kumar" <vijay(at)kinera(dot)com>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Problem with temporary table -- Urgent |
Date: | 2003-07-12 08:45:35 |
Message-ID: | 200307120945.36058.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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 := lString || '' create temporary table temp_Table( Name
> 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"
refers to a specific entry in the system-tables. When the temp-table gets
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
try to keep my function code in the same file as the table(s) they rely on,
that way I recreate both when I make changes.
--
Richard Huxton
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-07-12 13:36:53 | Re: time date interval... |
Previous Message | Erik Thiele | 2003-07-12 07:00:19 | time date interval... |