Re: [SQL] PL/PGSQL function with parameters

From: Florent Guillaume <efgeor(at)noos(dot)fr>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: pgsql-hackers(at)postgresql(dot)org, pgman(at)candle(dot)pha(dot)pa(dot)us
Subject: Re: [SQL] PL/PGSQL function with parameters
Date: 2001-02-06 21:15:22
Message-ID: 20010206221522.A21727@twin.efge.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

> > SQL = ''SELECT * INTO temp1 FROM '' || $1;
>
> I tried this, and it seems that "SELECT ... INTO foo" is not executed
> correctly by EXECUTE --- the INTO is handled as an ordinary select-into-
> table construct rather than plpgsql's select-into-variable.
>
> While I have not looked closely, I seem to recall that plpgsql handles
> INTO by stripping that clause out of the statement before it's passed to
> the SQL engine. Evidently that's not happening in the EXECUTE case.

From gram.y, yes it tries to strip the INTO by skipping over some stuff,
maybe the "*" trips it ?

Anyway the syntax SELECT INTO temp1 * FROM .... should work.

On this same subject, the plpgsql doc says to use
SELECT expression INTO var FROM ...
but Bruce's book, in several examples ("PL/PGSQL Functions" for instance,
node203.html) uses
SELECT INTO var expression FROM ...

Both should work, but there may be there's something to straighten up here.

Cheers,

Florent

--
florent(dot)guillaume(at)mail(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florent Guillaume 2001-02-06 21:21:15 Re: [PATCHES] A Sparc/Linux patch (for 7.1), and a Linux rc.d/init.d script....
Previous Message Gunnar R|nning 2001-02-06 20:26:59 Re: full text searching

Browse pgsql-sql by date

  From Date Subject
Next Message Guerrino Di Minno 2001-02-06 22:43:36 Datatype in SQL Server 2000
Previous Message Karel Zak 2001-02-06 18:49:12 Re: timestamp- milliseconds since epoch output