Subject Re: [firebird-support] GEN_ID Trigger
Author Martijn Tonies
Hi Dion,

> I am using ADO components to connect to a Firebird database. I have
created
> a trigger to genrerate a unique id for a table. When appending a record
to
> the table using IBOConsole, the new id value is not inserted into the
> relevant field, ie the trigger is not 'triggered'. It is active. Is this
> normal?

No it's not normal - you might want to change your trigger code to:

> CREATE TRIGGER "NEW_CONTACTS_ID" FOR "CONTACTS" ACTIVE
> ACTIVE BEFORE INSERT POSITION 0
> AS
> BEGIN
> IF (NEW.OBJID IS NULL) THEN

IF ( (NEW.OBJID IS NULL) OR (NEW.OBJID = 0) ) THEN

> NEW.OBJID = GEN_ID(GEN_CONTACT_ID, 1);
> END

As you're not telling what get's inserted, if at all.


With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird & MS SQL Server.
Upscene Productions
http://www.upscene.com