PL/pgSQL

Started by Wojciech Strza�kaover 23 years ago4 messagesgeneral
Jump to latest
#1Wojciech Strza�ka
wojtek_strzalka@interia.pl

i've got a simple plsql function and this line is wrong:

EXECUTE ''SELECT INTO lp MAX('' || column || '') AS MX FROM '' || table
|| '';'';

with error message:

"parse error at or near 'INTO' "

it seems like it don't recognize SELECT INTO - but what's wrong?

Thaks, Wojtek

#2Darren Ferguson
darren@crystalballinc.com
In reply to: Wojciech Strza�ka (#1)
Re: PL/pgSQL

Try

EXECUTE ''SELECT MAX(''||column||'') INTO lp FROM '' || table;

This should work but haven't tested it.

Normally with select into though is is

select foo into bar from aa where id = _id;

HTH

On Thu, 3 Oct 2002, Wojciech Strza�ka wrote:

i've got a simple plsql function and this line is wrong:

EXECUTE ''SELECT INTO lp MAX('' || column || '') AS MX FROM '' || table
|| '';'';

with error message:

"parse error at or near 'INTO' "

it seems like it don't recognize SELECT INTO - but what's wrong?

Thaks, Wojtek

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

--
Darren Ferguson

#3Patrick Welche
prlw1@newn.cam.ac.uk
In reply to: Wojciech Strza�ka (#1)
Re: PL/pgSQL

On Thu, Oct 03, 2002 at 04:53:26PM +0200, Wojciech Strza�ka wrote:

i've got a simple plsql function and this line is wrong:

EXECUTE ''SELECT INTO lp MAX('' || column || '') AS MX FROM '' || table
|| '';'';

with error message:

"parse error at or near 'INTO' "

it seems like it don't recognize SELECT INTO - but what's wrong?

How about

EXECUTE ''SELECT MAX('' || column || '') AS MX INTO lp FROM '' || table

?

Cheers,

Patrick

#4Bruce Momjian
bruce@momjian.us
In reply to: Wojciech Strza�ka (#1)
Re: PL/pgSQL

Wojciech Strza?ka wrote:

i've got a simple plsql function and this line is wrong:

EXECUTE ''SELECT INTO lp MAX('' || column || '') AS MX FROM '' || table
|| '';'';

with error message:

"parse error at or near 'INTO' "

it seems like it don't recognize SELECT INTO - but what's wrong?

In PL/pgSQL, you have to use CREATE TABLE ... AS because INTO has
another meaning in PL/pgSQL.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073