Subject Re: [IBO] Master/Detail and GENERATORS
Author Helen Borrie
At 12:47 AM 17/02/2003 +0000, you wrote:
>How to work correctly in a net with several inserts?
>
>I am needing help in catching the values of a TRIGGER or of a
>GENERATOR using IBO.
>
>Actually I am developing a system of sales and I need with urgency
>to know as to catch a GENERATOR without there is duplication of data
>among the users.
>
>I have the following fields:
>
>Table of Sales
>== == == == == == ==
>CODESALE
>...
>
>Table of requested products
>== == == == == == == == == == ==
>CODE PRODUCT
>CODESALE
>
>Did I already create a generator for CODESALE even so me precise to
>catch this value in advance because in a net as I can guarantee that
>other station doesn't catch the same code that of another stations?

No, generators "fire" independently of any user transaction. Once a
certain number is generated, it cannot be generated again. Therefore, it
is not possible for different transactions to catch the same generator value.

>When catching this value me precise to throw it in the table DETAIL
>in the field CODESALE. Would a functional example be possible of
>that? Using IBX I got to find a component that the number of
>GENERATOR came back. How to do that with IBO?

If you need to know the number of the generator inside your transaction,
then call the Gen_ID function of the connection or of the dataset, e.g.

NewNumber := MyIBODatatase.Gen_ID('MyGenerator', 1);

If you don't need to know what the number is, then set the GeneratorLinks
property. On the Dataset you would do this:

MyGeneratedField=MyGenerator

You can alternatively use the connection object's GeneratorLinks, to make
this available to *any* dataset which enables inserts to MyTable:

MyTable.MyGeneratedField=MyGenerator

regards,
Helen