From: | "Fernando Moreno" <azazel(dot)7(at)gmail(dot)com> |
---|---|
To: | "A B" <gentosaker(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: syntax error with execute |
Date: | 2008-05-30 21:22:32 |
Message-ID: | b1c45530805301422t3691050ai495c78ca610fb05b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I haven't use the RETURNING clause before, but the "INTO" option, at least
in SELECT sentences, must be outside of the string expression. This way:
EXECUTE 'some query' INTO variable;
Cheers.
2008/5/30 A B <gentosaker(at)gmail(dot)com>:
> 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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Brian Cox | 2008-05-30 22:09:30 | conditional alter table |
Previous Message | Gurjeet Singh | 2008-05-30 21:16:31 | Re: syntax error with execute |