Subject | Re: [IBO] generator isn't used |
---|---|
Author | Paul Vinkenoog |
Post date | 2003-09-17T22:56:51Z |
Hi Gediminas,
you Insert() a new record. It does not wait until you call Post(). You
can see this in a grid if you (temporarily) make the ID field Visible,
or in a TIB_Edit even if you leave the field invisible.
This also means that if you call Cancel() instead of Post(), the
generator will still be incremented by 1.
Please note that what we call an insert on the IBO side (call Insert()
or click the green "+" button or press Ins while in a Grid) is not the
same as an insert into the database. As long as a record is in
dssInsert state, it only exists in your application, not in the
database. Triggers aren't called at this stage.
Only when the newly inserted record is _posted_, an INSERT statement
will be sent to the server, the record will be inserted into the db
and the before/after insert triggers will fire - if they exist, and if
they are active.
do these values come from, if not from the generator? Do you set them
in code? Then they will overwrite the values from the generator,
because the generator is called before you can set any field values
yourself.
About the name "Gen_ID" - this is also the name of the FB function
that gets values from a generator, so it's not a good choice. But I
don't think that's what causing your problem, because you have it
double-quoted.
Unfortunately, it's also the name of an IBO function with the same
purpose. I don't think this will cause problems either, but it's
better to stay away from names like that!
If you can't think of anything, call it (almost) after yourself
Gen_ID_Minas. Or Gen_Siam_ID - a nice anagram of your name with a
touch of your former countryman Yul Brynner! :-)
Greetings,
Paul Vinkenoog
> For example have placed ib_query and assign values to fields by:If you have set up GeneratorLinks, IBO calls the generator as soon as
> ib_q1->FieldByName( "Name" )->AsString = "I";
> ib_q1->FieldByName( "Age" )->AsInteger = 20;
> and set ib_q1 GeneratorLinks to "Person_ID"="Gen_ID", but when
> posting (ib_q1->Post()) generator isn't used
you Insert() a new record. It does not wait until you call Post(). You
can see this in a grid if you (temporarily) make the ID field Visible,
or in a TIB_Edit even if you leave the field invisible.
This also means that if you call Cancel() instead of Post(), the
generator will still be incremented by 1.
Please note that what we call an insert on the IBO side (call Insert()
or click the green "+" button or press Ins while in a Grid) is not the
same as an insert into the database. As long as a record is in
dssInsert state, it only exists in your application, not in the
database. Triggers aren't called at this stage.
Only when the newly inserted record is _posted_, an INSERT statement
will be sent to the server, the record will be inserted into the db
and the before/after insert triggers will fire - if they exist, and if
they are active.
> as always first person ID is usedWhat do you mean by this? Do the Person_ID fields have a value? Where
do these values come from, if not from the generator? Do you set them
in code? Then they will overwrite the values from the generator,
because the generator is called before you can set any field values
yourself.
> (trigger isn't fired as well).How do you know it doesn't fire?
About the name "Gen_ID" - this is also the name of the FB function
that gets values from a generator, so it's not a good choice. But I
don't think that's what causing your problem, because you have it
double-quoted.
Unfortunately, it's also the name of an IBO function with the same
purpose. I don't think this will cause problems either, but it's
better to stay away from names like that!
If you can't think of anything, call it (almost) after yourself
Gen_ID_Minas. Or Gen_Siam_ID - a nice anagram of your name with a
touch of your former countryman Yul Brynner! :-)
Greetings,
Paul Vinkenoog