Re: Checking NULL value...
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration
risnull does not work in certain situations.
In SQL you can use NVL function to convert a null value into something
new and then look for that value.
eg NVL(age,0) = 0
or Within Esql/C
if ( age ) /**** not null ****/
if ( !age ) /**** NULL ****/
Vivek Chaudhary
______________________________ Reply Separator _________________________________
Subject: Checking NULL value...
Author: hughesb (hughesb@pacbell.net) at internet
Date: 5/6/00 1:11 PM
I am hoping someone can help me. My ESQL/C code is having difficulty
distiquishing between a column with a NULL value and a column = '\\0' (or "")
using a sqlda structure after a FETCH ... USING DESCRIPTOR ...
I have correctly DESCRIBED the statement into the sqlda structure and
allocated the memory accordingly. I have the following table:
CREATE TABLE test ( name char(16), value char(16) );
INSERT INTO test ( name, value ) values ( "test", "" );
INSERT INTO test ( name ) values ( "test1" );
If I use dbaccess and do a SELECT * FROM test WHERE value IS NULL, the row
with name = "test1" is returned.
In my ESQL/C code, immediately before the fetch sqlvar[...].sqlind is NULL
as well as immediately after for both rows. When I use the Informix library
call risnull(), it returns TRUE for both records.
Why is dbaccess able to determine that one row is NULL and the other is a
single character string with a NULL value?
Bryan Hughes
Shutterfly.com
--
------------------------------------------------------------
"A doctor can bury his mistakes but an architect can only
advise his client to plant vines." -- Frank Lloyd Wright
Hi,
for ESQL/C using of an indicator variable is everytime the best solution.
Example:
$char name[17], value[17];
$int ind1, ind2;
$declare xTest cursor for select name, value from test;
$open xTest;
while (SQLCODE==0)
{
$fetch xTest into $name:ind1, $value:ind2;
if (SQLCODE==0 && ind1!=-1 && ind2!=-1) -- perhaps both != NULL
.......
}
close, free etc.
HTH
Dirk
Vivek.CHAUDHARY@st.com schrieb:
> risnull does not work in certain situations.
>
> In SQL you can use NVL function to convert a null value into something
> new and then look for that value.
>
> eg NVL(age,0) = 0
>
> or Within Esql/C
>
> if ( age ) /**** not null ****/
> if ( !age ) /**** NULL ****/
>
>
> Vivek Chaudhary
>
> ______________________________ Reply Separator _________________________________
> Subject: Checking NULL value...
> Author: hughesb (hughesb@pacbell.net) at internet
> Date: 5/6/00 1:11 PM
>
> I am hoping someone can help me. My ESQL/C code is having difficulty
> distiquishing between a column with a NULL value and a column = '\\0' (or "")
> using a sqlda structure after a FETCH ... USING DESCRIPTOR ...
>
> I have correctly DESCRIBED the statement into the sqlda structure and
> allocated the memory accordingly. I have the following table:
>
> CREATE TABLE test ( name char(16), value char(16) );>
> INSERT INTO test ( name, value ) values ( "test", "" );
> INSERT INTO test ( name ) values ( "test1" );>
> If I use dbaccess and do a SELECT * FROM test WHERE value IS NULL, the row
> with name = "test1" is returned.
>
> In my ESQL/C code, immediately before the fetch sqlvar[...].sqlind is NULL
> as well as immediately after for both rows. When I use the Informix library
> call risnull(), it returns TRUE for both records.
>
> Why is dbaccess able to determine that one row is NULL and the other is a
> single character string with a NULL value?
>
> Bryan Hughes
> Shutterfly.com
>
> --
>
> ------------------------------------------------------------
> "A doctor can bury his mistakes but an architect can only
> advise his client to plant vines." -- Frank Lloyd Wright
>
>