Re: create temp in function

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: create temp in function
Date: 2008-04-22 05:12:08
Message-ID: 20080422051208.GA6842@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin 2008-04-22 05:33:53 Re: PostgreSQL on Vista
Previous Message Clemens Schwaighofer 2008-04-22 04:58:01 Postgres Encoding conversion problem