Subject Re: [firebird-support] Stored procedure to return primary key after insert
Author Nick Upson
you need to put a colon in front of the variable names in the insert statement

INSERT INTO MEMBERS VALUES(:id_mem, :fn, :sn, :fln, :sln);

strongly suggest explicitly listing the column names in the insert
statement rather than rely upon their order never changing.

On 29/09/06, killerion <killerion@...> wrote:
> I'm using a stored proc to insert into a table and return the
> generated primary key, but always says column not found, I doubt the
> problem is in the insert statement... here is a copy of the stored proc:
> CREATE PROCEDURE PRCDR_INSERT_MEMBER (
> CODE_MEM VARCHAR(15),
> FN VARCHAR(25),
> SN VARCHAR(10),
> FL VARCHAR(10),
> SLN VARCHAR(10))
> RETURNS (
> ID_MEM INTEGER)
> AS
> begin
> id_mem = gen_id( GEN_ID_MEMBER, 1 );
> CODE_MEM = CODE_MEM || id;
> INSERT INTO MEMBERS VALUES(id_mem, fn, sn, fln, sln);
> end^
>
> I've tried declaring a variable instead of using id_mem and assigning
> the variable to id_mem after the insert but same error...
>
> James