Subject RE: [firebird-support] Find Generator Value Used after Insert Trigger
Author Nigel Weeks
>
> > set term !! ;
> > CREATE PROCEDURE sp_ins_tablename(
> > F1 integer,
> > F2 VARCHAR(20),
> > F3 VARCHAR(20)
> > ) RETURNS (
> > int_newkey NUMERIC(18,0)
> > )
> > AS BEGIN
> > /* Get a new generator value */
> > int_newkey = gen_id(generator_name,1);
> > /* Insert it into the table */
> > insert into table (pkeyfield, F1, F2, F3)
> > values (:int_newkey,:F1, :F2, :F3);
> > SUSPEND; <-------------------------------------
>
>
> As I know (may be inaccurate) there is no need to put SUSPEND
> here in this
> procedure.
>

Incorrect
You need a 'SUSPEND' in a stored procedure if you run the procedure with a
'SELECT', and want something to be returned.

In this case, we inserted a record with a select statement:
select * from sp_ins_tablename(F1,F2,F3);

and it gives us the returns (Via the suspend)

int_newkey
---------------------
1

You don't need the 'suspend' if you're making an execute only procedure, or
if you don't want any returns from the DB.

N.