Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP9 and null values and NVL()
Message
From
25/07/2006 09:00:53
 
 
To
24/07/2006 20:23:04
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01139317
Message ID:
01139646
Views:
25
I see that now. Basically we have a bit field in SQL that is used for logical values. It allows nulls and the default value is false. Of course, it is a new field which we had with the update and new default values are set to false but existing records are left as null during the update. The majority of the records will have a null value. In most cases, we pull the record only if it is false or null, but not true. In our Select statemens we have:

(ISNULL(inactive,0)!=1)

when the result returned is filtered on only returning records that are not marked as inactive. Many times we have the field in a different result set though based on other queries and in that case we step through the result set in VFP and use:

IF !(NVL(logicalfield,.F.)) && check for false

or

IF (NVL(logicalfield,.F.)) && check for true

It looked in testing as if the nulls were behaving as false (which would be fine since the default value in the field is false) and didn't require the NVL(). I just wanted to be sure whether or not that would
always be the case. In other words:

IF !logicalfield && check for false

appeared to work as well when the value was null and not false. I couldn't be certain though based on my limited understanding of how VFP handles null values in cursors. I was playing it 'safe' with the NVL() I think. I tested 65,000,000 records using both methods and the speed difference between the two was negligible. I've had strange result sets returned when the very first record returned contained a null value though (VFP would sometimes created a different field type instead of a logical field) so I wanted to be sure.




>>I must be totally not undertanding the help:
>>
>>
>>Null values persist through logical expressions in most cases. The following table describes the behavior of null values in logical expressions.
>>
>>Logical expression  Result if x=TRUE  Result if x=FALSE  Result if x=.NULL.
>>x AND .NULL.            .NULL.             FALSE               .NULL.
>>x OR .NULL.              TRUE              .NULL.              .NULL.
>>NOT x                   FALSE              TRUE                .NULL.
>>
>>
>This table just shows how the shorthand evaluation works - if the value of the logical expression can be decided from the first operand, then the second isn't evaluated.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform