Re: create temp in function - Mailing list pgsql-general

From A. Kretschmer
Subject Re: create temp in function
Date
Msg-id 20080422051208.GA6842@a-kretschmer.de
Whole thread Raw
In response to create temp in function  ("Kerri Reno" <kreno@yumaed.org>)
List pgsql-general
am  Mon, dem 21.04.2008, um 15:22:52 -0600 mailte Kerri Reno folgendes:
> But if I create and run the following function, it bombs on the second run.  It
> gives me:
> compassdevel_lb=# select testtemp();
> NOTICE:  relid: 186270497
> NOTICE:  count: 0
>  testtemp
> ----------
>  t
> (1 row)
>
> compassdevel_lb=# select testtemp();
> NOTICE:  relid: <NULL>
> ERROR:  relation with OID 186270497 does not exist
> CONTEXT:  SQL statement "SELECT  count(*) from schedrec"
> PL/pgSQL function "testtemp" line 9 at select into variables
>
> Here is my function:
> create or replace function testtemp()
>     returns boolean as
> $body$
> declare
>     query text;
>     relid integer;
>     cnt integer;
> begin
>     create temp table schedrec (sch text, cl text, st text);


Use EXECUTE for DDL-Statements within function, because the planner
cached the OID's.

Other solution: use 8.3.

More details about that:
http://merlinmoncure.blogspot.com/2007/09/as-previously-stated-postgresql-8.html

Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

pgsql-general by date:

Previous
From: Clemens Schwaighofer
Date:
Subject: Postgres Encoding conversion problem
Next
From: "Albe Laurenz"
Date:
Subject: Re: Postgres Encoding conversion problem