Subject | Re: [firebird-support] Re: INSERT INTO ... RETURNING with EXECUTE STATEMENT |
---|---|
Author | Tim Ward |
Post date | 2014-06-24T10:48Z |
The procedure does compile, but when I run it I get23.06.2014 14:48, Tim Ward tdw@... [firebird-support] wrote:
>
> I've got an INSERT statement like:
>
> INSERT INTO <table>( <list of columns> )
> SELECT <list of columns>
> FROM <table whose name is not known until run time>
> WHERE <something
> RETURNING generated_primary_key INTO :variable
>
> the point being that the name of the table used in the FROM isn't known
> until run time. This needs to be inside a stored procedure for Firebird 2.1.
>
> Elsewhere (simple SELECT, FOR SELECT) I've worked out how to do this
> using EXECUTE STATEMENT.
>
> But what, please, is the correct syntax for using EXECUTE STATEMENT for
> an INSERT INTO ... SELECT ... RETURNING? - this isn't an example usage
> which I've been able to find in any of the documentation.
I believe it should be:
EXECUTE STATEMENT 'INSERT INTO ... SELECT ... RETURNING
generated_primary_key' INTO :variable;
Dmitry
"request synchronization error"
at that statement.
-- Tim Ward