Re: PL/pgSQL examples NOT involving functions - Mailing list pgsql-sql

From
Subject Re: PL/pgSQL examples NOT involving functions
Date
Msg-id 200111280034.09d3@lh00.opsion.fr
Whole thread Raw
In response to PL/pgSQL examples NOT involving functions  (Roland Roberts <roland@astrofoto.org>)
Responses Re: PL/pgSQL examples NOT involving functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Hello!

> envisity=# create table temp (tempid integer);
> CREATE
> envisity=# INSERT INTO temp VALUES(1);
> 
> CREATE FUNCTION test3() RETURNS INTEGER AS 'DECLARE
id INTEGER; BEGIN SELECT INTO id tempid FROM temp
LIMIT 1; RETURN id; END;' LANGUAGE 'plpgsql';
> DROP
> CREATE
> envisity=# select test3();
>  test3
> -------
>      1
> (1 row)
> 
> envisity=# DROP TABLE temp ;
> DROP
> envisity=# create table temp (tempid integer);
> CREATE
> envisity=# INSERT INTO temp VALUES(3);
> INSERT 150371 1
> envisity=# select test3();
> ERROR:  Relation 150348 does not exist

If I exit plpgsql and reenter, then "select test3()"
works again. So I guess "the first time" in

"The PL/pgSQL call handler parses the function's
source text and produces an internal binary
instruction tree the first time the function is
called."

might be referring to "for each client connection".

CN

--------------------------------------------------------
You too can have your own email address from Eurosport.
http://www.eurosport.com







pgsql-sql by date:

Previous
From: "Josh Berkus"
Date:
Subject: Re: Complex query help please
Next
From: Roberto Mello
Date:
Subject: Re: hu.po