Subject Re: [IBO] getting sequence val before insert
Author Paul Vinkenoog
Hi Ronan,

> I am using an SP to INSERT a record. One of the output params in the
> SP is the row_id that will be used for the to-be-inserted record.

You say "to-be-inserted". Does this mean the SP doesn't insert the
record itself?

> For now I am using O_ROW_ID= GEN_ID(GEN_E_PROJECT_ROW_ID, 1)-1;
> to get the right row_id.

Within the SP? And O_ROW_ID is the output param you mentioned? BTW,
why do you subtract 1? This gives you a number that has been generated
before, which means *danger*.

If you just need a unique ID for your record, generate it in a before
insert trigger like this:

if ( New.MyID is null )
then New.MyID = gen_id( gen_e_project_row_id, 1 );

If you want IBO to insert the ID for you so it can keep track of the
record without a refresh, you can set up the dataset's GeneratorLinks.

If your application must know the value of the generated ID before
insertion into the record, use the Gen_ID or GeneratorValue method
from your dataset.

Look at the IBO Help to see how to use these properties and methods.

If this information is not enough, please tell us more about what you
have (in the SP, in a trigger if you have one, and in your app) and
what you want to achieve.

Paul Vinkenoog