Subject Re: [firebird-support] Set term gives Token unknown error
Author Aage Johansen
Stevio wrote:
>>> ...
>>> CREATE PROCEDURE PROC_NEW_LETABLE_ID
>>> RETURNS (THE_NEW_LETABLE_ID INTEGER)
>>> AS
>>> BEGIN
>>> THE_NEW_LETABLE_ID = GEN_ID(GEN_NEW_LETABLE_ID, 1);
>> You will need a SUSPEND here!
>>> END ^
>>> SET TERM ; ^
>> Do another commit.
>
> What does suspend do and why do I need it?
>
> What is the actual line of SQL code that should be added? Is it:
> SUSPEND;
> or
> SUSPEND ^
>
> ...

suspend;

It allows the procedure to return values to the caller. It is often
used to return values from a "for select ... into ..." construct.

If you created a "before insert" trigger you could just use something like:
set term ^;
create trigger ...
active before insert
as
begin
new.THE_NEW_LETABLE_ID = GEN_ID(GEN_NEW_LETABLE_ID, 1);
end ^
set term ;^
commit;
If your application doesn't need to know the actual value, then a
trigger is a good solution - you would not need the procedure.


A copy of Helen Borrie's "Firebird book" will be a good investment
(if you don't already own it).


--
Aage J.