MSSQL Execute SQL returning NULL to variable cannot be checked for using string if logic


(Heath) #1

Version: 8.0.0.2442
Issue: MyVariable is shown in log containing NULL, but IF test to value “NULL”, returns FALSE.

  1. Using MSSQL Execute SQL (SQLCmd) attempt to select data that does not exist (returns NULL into MyVariable, this is seem in the log.
  2. Trip the value to get rid of whitespace.
  3. Check if variable contains NULL using a simple IF =.

(Vincent Parrett) #2

Can you show us an example project of what you are doing?

I’m not able to reproduce this here, at least in my simple test.


(Heath) #3

Hi Vincent,

Sorry, forgot to get back to you.

The SQL field needs to be flagged as nullable. Ensure there is no value. When you use FinalBuilder to read it, it returns a “NULL” string, but none of the string compare functions regonise it as “NULL”.

Regards,
Heath


(Vincent Parrett) #4

The problem with the IF Then action, is that it is comparing strings (because it evaluates variable expressions, not variables). It does do some type coersion where it can, for example if both sides are integers it will do an integer comparison. But strings in FinalBuilder don’t understand null as such. In this case you might want to resort to using a condition on a group action. Conditions are a boolean expression that determines if the action is run or skipped :

FBVariables.MyVariable != null 

(Heath) #5

I understand the challenge, but it’s very confusing as FinalBuilder outputs NULL in the log, which I assumed would be a string matchable. Even if the Execute SQL query returned empty string for NULL, that would be a lot better.

This is what I see in the output window.
image