Subject | RE: [IBO] Re: Auto-Incrementing Key Field |
---|---|
Author | Jack Cane |
Post date | 2002-10-14T00:48:18Z |
I'm using TIBOdataBase and tIBOquery with tDataSource and tdbEdit. Cannot
find the OnBeforePost event.
Plse see also, reply to Frank.
I'm pretty new to all of this.
tks,
jwc
-----Original Message-----
From: Marco Menardi [mailto:mmenaz@...]
Sent: Sunday, October 13, 2002 4:09 PM
To: IBObjects@yahoogroups.com
Subject: [IBO] Re: Auto-Incrementing Key Field
find the OnBeforePost event.
Plse see also, reply to Frank.
I'm pretty new to all of this.
tks,
jwc
-----Original Message-----
From: Marco Menardi [mailto:mmenaz@...]
Sent: Sunday, October 13, 2002 4:09 PM
To: IBObjects@yahoogroups.com
Subject: [IBO] Re: Auto-Incrementing Key Field
--- In IBObjects@y..., "Jack Cane" <jwcane@e...> wrote:
> I have configured the key field as an auto-incementing integer. I have
it
> hooked to a tdbEdit whose read-only property is set to true. When I
press
> the 'Post' button of my tdbNavigator an exception is raised with
message,
> "(Field name) is a required field".
As far as I remember, the error is a client-side error. If you fill the
autoincrement field only at database level, you have to set that field as
"not required".
The best aproach is having the trigger that assign the field value using a
generator that checks if the field is null (and assigns the value only if
null), and then use the IB_Query.GeneratorLinks property for having the
field value automatically assigned at client level before the post (it's
assigned when you enter the Insert state), or use OnBeforePost to assign the
value to the field (so it's assigned only when/if posted).
the code I suggest in the trigger is like:
...
IF ((NEW.MovCon_ID IS NULL) OR (NEW.MovCon_ID < 1)) THEN
BEGIN
NEW.MovCon_ID = gen_id(MovCon_ID_GEN, 1);
END
...
then '<1' condition is there to let you assign a negative value and escape
a client check for "not null" assignment to that field, in the case you are
using tools like IB_SQL to perform manual manteinance of the database.
For the OnBeforePost, there is a useful property of IB_Query:
with qryMovConRighe do
begin
FieldByName('RIGA_ID').AsInt64 := Gen_ID('RIGA_ID_GEN', 1);
end;
where 'RIGA_ID' is the key field, and 'RIGA_ID_GEN' is the name of the
generator used to fill it.
regards
Marco Menardi
Yahoo! Groups Sponsor
ADVERTISEMENT
___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or
InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info
papers,
keyword-searchable FAQ, community code contributions and more !
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]