Subject | Re: [firebird-support] Stored procedure to return primary key after insert |
---|---|
Author | Thierry Holtzmann |
Post date | 2006-09-29T15:33:06Z |
You should put colons before variables at the right side of affectation.
ie
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^
bt the way id is not defined, did you mean :id_mem ?
killerion a écrit :
ie
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^
bt the way id is not defined, did you mean :id_mem ?
killerion a écrit :
>
> 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
>
>