Subject Re: [IBO] Re: How to use bookmarks like tTable and tQuery?
Author Andrei Luís
Is there any problem to use the trigger like I posted? Because it's a
trigger only or Before Insert event...

I tried to use triggers like u said when I was learning about Firebird
+ IBO, but, I was getting error messages in Delphi like "Registro_id
is a required field and cannot be null", and so I suppres "IF
(NEW.REGISTRO_ID IS NULL) THEN" and set registro_id to receive 0
(zero) as default value in IBO.

After I changed all my triggers and code like this, I heard about
setting registro_id field to a not required field, but, sincerely, I
didn't do any change...

I will test and put the result here.

[]
Andrei

2005/12/7, Thomas Steinmaurer <ts@...>:
> > SET TERM ^ ;
> >
> > CREATE TRIGGER TRIG_AGENDA_BI_0 FOR AGENDA
> > ACTIVE BEFORE INSERT POSITION 0
> > AS BEGIN
> > NEW.REGISTRO_ID = GEN_ID(GEN_AGENDA_REGISTRO_ID,1);
> > END
> > ^
> >
> > SET TERM ; ^
>
> Thought so. Extend that to:
>
> SET TERM ^ ;
>
> CREATE TRIGGER TRIG_AGENDA_BI_0 FOR AGENDA
> ACTIVE BEFORE INSERT POSITION 0
> AS
> BEGIN
> IF (NEW.REGISTRO_ID IS NULL) THEN
> NEW.REGISTRO_ID = GEN_ID(GEN_AGENDA_REGISTRO_ID,1);
> END
> ^
>
> SET TERM ; ^
>
>
> And you will be fine, because REGISTRO_ID won't get a new value again,
> thus IBO will have the correct value of REGISTRO_ID for a newly inserted
> record.
>
>
> --
> HTH,
> Thomas Steinmaurer
> LogManager Series - Logging/Auditing Suites supporting
> InterBase, Firebird, Advantage Database, MS SQL Server and
> NexusDB V2
> Upscene Productions
> http://www.upscene.com