Subject Re: [firebird-support] Autoincremented Fields in Delphi
Author Mitchell Peek
gato2707 wrote:

>Hi everybody:
>
>I'm trying to use an autoincrement field in a table, the field is part
>of the primary key. First I used a trigger calling a generator, but
>when insert a new record in my Delphi application i discover is
>neccesary to write any value in the field BEFORE the post operation,
>otherwise an error occurs. Then I read best way to do that is thru a
>StoredProcedure, well, I cant't find where call that procedure. Any
>sugestion?
>
>
>
No, a trigger.

Create Generator gen_MYNAME;

>CREATE TABLE MYNAMES
>(
> MYCODE INTEGER,
> MYNAME CHAR(30)
>)
>
>CREATE trigger t_myname_bi for myname before insert as
>AS
>BEGIN
>
>
if (new.mycode is null) then

> NEW.myCODE = GEN_ID(gen_myname, 1);
>END
>
>
>
>
>
>