Subject Re: Autoincremented Fields in Delphi
Author Genilton Barbosa
I migrated a database from Paradox to Firebird unsing the migration
tool IBPump. IBPump create generators and triggers to simulate
autoinc fields.

The autoinc simulation is not working if the autoinc fields are used
in primary keys (NOT NULL constraint). It looks like the constraint
is checked before the execute of the trigger.

What can I do?

Genilton Barbosa
Brazil


--- In firebird-support@yahoogroups.com, Mitchell Peek <mitchp@h...>
wrote:
> 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
> >
> >
> >
> >
> >
> >