Re: 'Select INTO" in Execute (dynamic query )

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: dpandey(at)secf(dot)com
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: 'Select INTO" in Execute (dynamic query )
Date: 2005-04-18 17:26:49
Message-ID: 23848.1113845209@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

"Dinesh Pandey" <dpandey(at)secf(dot)com> writes:
> What's wrong with this code (ERROR: syntax error at or near "INTO" at
> character 8)?

You can't use plpgsql's SELECT INTO in an EXECUTE'd command, because
SELECT INTO means something entirely different to the main SQL engine.

The usual workaround is to use FOR ... IN EXECUTE. See the plpgsql docs.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Relyea, Mike 2005-04-18 18:51:24 Plpgsql function with unknown number of args
Previous Message Matt Van Mater 2005-04-18 17:24:42 Re: *bsd port that installs the contribs?

Browse pgsql-sql by date

  From Date Subject
Next Message A. Kulikov 2005-04-18 18:32:26 User Defined Functions Errors
Previous Message Dinesh Pandey 2005-04-18 16:04:48 'Select INTO" in Execute (dynamic query )