Jump to content
Sign in to follow this  
sunny

How To handle null values?

Recommended Posts

sunny

Friends,

Some of my queries are returning null values

How can i check whether it is null or not?

Is there any keyword called NULL so that i can compare my value with that keyword to determine whether its null or not

Regards

Share this post


Link to post
Share on other sites
Qousio

Friends,

Some of my queries are returning null values

How can i check whether it is null or not?

Is there any keyword called NULL so that i can compare my value with that keyword to determine whether its null or not

Regards

$Var = 0
MsgBox( 0, "Its null!", $Var)

;or

If $Var = 0 Then
    MsgBox( 0, "Its null!", $Var)
    EndIf

Share this post


Link to post
Share on other sites
Bowmore

AutoIt has no NULL keyword.

One method I have used is:

If StringLen($value) = 0 Then
    MsgBox( 0, "$value = ", "Null")
Else
    MsgBox( 0, "$value = ", $value)
EndIf

which works for both string and numeric fields


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
Yashied
trancexx

In some cases, you should use IsPtr(0). I also asked this question. See this.

What cases for example?

...anyway, if you need to check if something is not nothing then you would probably do it like this:

$iValue = 0
If $iValue Then
    ;...
Else
    ConsoleWrite("! iValue in not" & @CRLF)
EndIf

$sValue = ""
If $sValue Then
    ;...
Else
    ConsoleWrite("! sValue in not" & @CRLF)
EndIf

$fValue = False
If $fValue Then
    ;...
Else
    ConsoleWrite("! fValue in not" & @CRLF)
EndIf

Or maybe:

If Not $iValue ...

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Yashied
Juvigy

Maybe it is a good idea to add another UDF in the SQL UDF's that checks for "NULL" values or just modify the query functions to indicate when they return "NULL" ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.