Currently, I am able to retrieve values from IBM DB2. What I needed to be able to do is see what that value looks like if it is null.
In my code I set up a conditional statement that checks for most null values except I apparently do not know what a null value would like if it is retrieved from DB2 in my C code.
Currently I have:
if(pchr == NULL || pchr == "Null" ||
pchr == "NULL" || pchr == '\0' || pchr == “null”)
where pchr is a character pointer.
Apparently this conditional statement cannot detect the null value from DB2. Any help would be awesome
Null is usually indicated with a separate variable. For DB2 embedded SQL, it looks something like this:
EXEC SQL BEGIN DECLARE SECTION; VARCHAR pchr[PCHR_LEN+1]; /* nullable field we're interested in */ short pchrInd; /* flag indicating field is currently null */ EXEC SQL END DECLARE SECTION; ... EXEC SQL SELECT phcr INTO :pchr:pchrInd FROM table; // or SELECT pchr INTO :pchr INDICATOR :pchrInd if ( pchrInd ) // pchr is null else // process pchr