Subject Re: [IBO] IB Generators??
Author Helen Borrie
At 09:10 AM 22-05-01 -0700, you wrote:
>Hi all,
>
>I know this may seem silly but, i'm doing this conversion and I have this
>problem.
>
>I created a generator, and then an insert trigger, am I able to use this to
>update another field in the table without messing up the counter? if yes how?

No. The generator will keep incrementing each time someone inserts a row. Each time it is called upon, it will return the next number.

If a transaction is rolled back for some reason, then there will be a gap in the sequence of the numbers.


>would like to update a field and keep the counter correct.

It's not clear what this means. Are you wanting this number to reflect the creation order of the rows, or what?

>presently I am
>doing it like this.
>
>datamodule1.IBOtable1.fieldbyname('dispno').asinteger :=
> form2.wwtable3.fieldbyname('dispno').asinteger
>+ 1;
>
>I tried this but get an error undeclared identifier 'GEN_ID'.
>
>datamodule1.IBOtable1.fieldbyname('dispno').asinteger :=
> GEN_ID("GEN_DISP_LEG_DISPNO",1);
>
>
>Help someone please.

Gen_ID is a method of the IB_Connection object, or of the statement itself, not a global method or a native Delphi VCL method. Somehow you have to get at the wrapped TIB_Connection or TIB_Dataset to access their method, so you need an identifier for it, e.g.
datamodule1.IBODataBase1.Gen_ID(GEN_DISP_LEG_DISPNO,1) or datamodule1.IBOTable1.IB_Dataset.Gen_ID(GEN_DISP_LEG_DISPNO,1) might work.

(Please don't tell me you defined this generator name with double-quotes!!!)

The Insert trigger looks OK. One easy (easier?) alternative open to you is to add BEFORE UPDATE triggers to achieve the same as you are doing now with the INSERT trigger.

Cheers,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________