Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Nulls in an index
Tue, Dec 4 2007 6:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate 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 AMPermanent 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 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate 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 AMPermanent 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 AMPermanent 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 AMPermanent 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 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Eryk


I can say with reasonable certainty that in this case its either a non-zero number or null - honest Smiley

Roy Lambert
Tue, Dec 4 2007 11:15 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Robert


Human interface

Roy Lambert
Tue, Dec 4 2007 12:27 PMPermanent 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
>

Image