Subject | Re: Stored procedure to return primary key after insert |
---|---|
Author | Adam |
Post date | 2006-09-29T23:55:37Z |
> CREATE PROCEDURE PRCDR_INSERT_MEMBER (Use semi colons where you want to include variables on the right hand
> CODE_MEM VARCHAR(15),
> FN VARCHAR(25),
> SN VARCHAR(10),
> FL VARCHAR(10),
> SLN VARCHAR(10))
> RETURNS (
> ID_MEM INTEGER)
> AS
> begin
side.
> id_mem = gen_id( GEN_ID_MEMBER, 1 );Well for a start, the following will fail, where is id defined?
> CODE_MEM = CODE_MEM || id;Assuming you meant.
CODE_MEM = :CODE_MEM || :id_mem;
Note that if Code_Mem is null, you may need to use coalesce otherwise
it will still be null at this point.
> INSERT INTO MEMBERS VALUES(id_mem, fn, sn, fln, sln);Adam
> end^