Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Expression evaluation
Sun, Feb 18 2007 12:34 AMPermanent Link

Bill Edwards

If the following integer field is NULL, will the following expression evaluate as 1) false or 2) indeterminant?

If ( FieldByName('ItemNo').AsInteger > 0 )
Sun, Feb 18 2007 7:06 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Bill


My money is on 1). Whilst the SQL standard has (IMHO) horrible things to say about null .AsInteger has to do something with it and I think that something is treat it as zero.

Roy Lambert
Mon, Feb 19 2007 6:56 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bill,

<< If the following integer field is NULL, will the following expression
evaluate as 1) false or 2) indeterminant?

If ( FieldByName('ItemNo').AsInteger > 0 )  >>

False because Delphi doesn't know anything about NULL values.  To determine
if a field is NULL, use the TField.IsNull property instead.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Feb 19 2007 2:29 PMPermanent Link

Sean McCall
Bill Edwards wrote:
> If the following integer field is NULL, will the following expression evaluate as 1) false or 2) indeterminant?
>
> If ( FieldByName('ItemNo').AsInteger > 0 )
>
All the TField.AsXXX will return a value. For a null field, the value is:

Boolean ==> False
String ==> ''
Numeric ==> 0 (This includes TDateFields which evaluate to Dec 31, 1899
or something like that)

So, this expression will evaluate to False if the field 'ItemNo' is null.

Sean
Image