Re: syntax error with execute - Mailing list pgsql-general

From Scott Marlowe
Subject Re: syntax error with execute
Date
Msg-id dcc563d10805301321k6e602963ie889312715ce56f9@mail.gmail.com
Whole thread Raw
In response to syntax error with execute  ("A B" <gentosaker@gmail.com>)
Responses Re: syntax error with execute  ("Vyacheslav Kalinin" <vka@mgcp.com>)
List pgsql-general
Pretty sure you have to create the query as a string and execute that.

On Fri, May 30, 2008 at 9:55 AM, A B <gentosaker@gmail.com> wrote:
> I have a query like this in a plpgsql function:
>
> EXECUTE 'INSERT INTO '||tablename||' ('||fields||') VALUES
> ('||vals||') RETURNING currval('''||seqname||''') INTO newid'
>
> and I get the response:
>
> ERROR:  syntax error at or near "INTO"
> LINE 1: ...','2008','4',NULL) RETURNING currval('id_seq') INTO newid
>
> And I do not understand this error. If I take the INSERT command and
> run it by hand, it works fine, but it doesn't work in the function
> when called by execute. Anybody has an idea on what is wrong and what
> to do about it?
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

pgsql-general by date:

Previous
From: PJ
Date:
Subject: phpeclipse debugging & setup
Next
From: "Ed Fialkowski"
Date:
Subject: Re: small table, huge table, and a join = slow and tough query. cake inside!