Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 9 of 9 total |
Nulls in an index |
Tue, Dec 4 2007 6:00 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | I just spent about 30 minutes trying to figure out why a locate wasn't working, and to help other poor souls its because .AsInteger and field contents differ when the field is NULL so you end up having to test and produce a different locate statement depending on if its null or not.
if dbisamquery1.fieldbyname('_left').asinteger = 0 then c2c.locate('_contact;_company;_left', vararrayof([dbisamquery1.fieldbyname('_contact').asstring,dbisamquery1.fieldbyname('_company').asstring,null]),[]) else c2c.locate('_contact;_company;_left', vararrayof([dbisamquery1.fieldbyname('_contact').asstring,dbisamquery1.fieldbyname('_company').asstring,dbisamquery1.fieldbyname('_left').asinteger]),[]) Roy Lambert PS for visual and human interaction reasons I can't default the column to 0, not without a lot of work playing with displays. |
Tue, Dec 4 2007 8:05 AM | Permanent Link |
"Robert" | "Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message news:5E9331AA-EC3E-4693-8147-D2DB296AF043@news.elevatesoft.com... >I just spent about 30 minutes trying to figure out why a locate wasn't >working, and to help other poor souls its because .AsInteger and field >contents differ when the field is NULL so you end up having to test and >produce a different locate statement depending on if its null or not. > > if dbisamquery1.fieldbyname('_left').asinteger = 0 > then > c2c.locate('_contact;_company;_left', > vararrayof([dbisamquery1.fieldbyname('_contact').asstring,dbisamquery1.fieldbyname('_company').asstring,null]),[]) > else > c2c.locate('_contact;_company;_left', > vararrayof([dbisamquery1.fieldbyname('_contact').asstring,dbisamquery1.fieldbyname('_company').asstring,dbisamquery1.fieldbyname('_left').asinteger]),[]) > > > Roy Lambert > > PS for visual and human interaction reasons I can't default the column to > 0, not without a lot of work playing with displays. Which means that in your case, NULL is not equal to Zero, and therefore it is perfectly appropriate to have two different locates. Of course in most cases, you just default integers and currencies to zero. BTW, I think your statements are reversed. Robert |
Tue, Dec 4 2007 9:05 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Robert
>BTW, I think your statements are reversed. Nope. if dbisamquery1.fieldbyname('_left').asinteger = 0 means that its got nothing in it Roy Lambert |
Tue, Dec 4 2007 9:42 AM | Permanent Link |
"Robert" | "Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message news:FE628658-D115-4862-A274-5DD2E4EE713F@news.elevatesoft.com... > Robert > > >>BTW, I think your statements are reversed. > > Nope. if dbisamquery1.fieldbyname('_left').asinteger = 0 means that its > got nothing in it > so if 0 = null, why not initialize the field to zero? R > Roy Lambert > |
Tue, Dec 4 2007 9:53 AM | Permanent Link |
Eryk Bottomley | Roy,
> Nope. if dbisamquery1.fieldbyname('_left').asinteger = 0 means that its got nothing in it No, it might either be NULL or contain the value 0. You should be testing for Field.IsNull rather than Field.AsInteger = 0 because in the latter case the locate will fail because 0 IS NOT NULL. Eryk |
Tue, Dec 4 2007 10:24 AM | Permanent Link |
Bruno Krayenbuhl | ...
c2c.locate('_contact;_company;_left', vararrayof([dbisamquery1.fieldbyname('_contact').asstring,dbisamquery1.fieldbyname('_company').asstring,dbisamquery1.fieldbyname('_left').asinteger]),[]) ... ----------- dbisamquery1.fieldbyname('_left').asinteger = 0 casts (dbisamquery1.fieldbyname('_left').IsNull=True) to 0 -> but they dont have the same meaning may be you could try to write it as c2c.locate('_contact;_company;_left', vararrayof([dbisamquery1.fieldbyname('_contact').asstring,dbisamquery1.fieldbyname('_company').asstring,.fieldbyname('_left').Value]),[]) Bruno Krayenbuhl |
Tue, Dec 4 2007 11:15 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Eryk
I can say with reasonable certainty that in this case its either a non-zero number or null - honest Roy Lambert |
Tue, Dec 4 2007 11:15 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Robert
Human interface Roy Lambert |
Tue, Dec 4 2007 12:27 PM | Permanent Link |
"Robert" | "Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message news:F1E25F93-A7B1-44EF-A459-CA955B0BB29E@news.elevatesoft.com... > Robert > > > Human interface > Darn humans. Always creating trouble for our software. Robert > Roy Lambert > |
This web page was last updated on Thursday, May 23, 2024 at 07:54 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |