esql/c empty string
Posted in 2004
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design
I'm using 'char' type host variabile to insert data into a VARCHAR(20,0).
I do the following:
char x[21];
strcpy(x,"");
But I see that value inserted is "NULL".
Therefore I try to use an 'indicator' variable (indicator=0)
but I got the same result ("NULL").
For backward compatibility I need to execute a select as:
SELECT * FROM table WHERE my_field="";
Gianluca wrote:
> I'm using 'char' type host variabile to insert data into a VARCHAR(20,0).
>
> I do the following:
>
> char x[21];
> strcpy(x,"");
This, to informix, is a null string.
strcpy(x, " ");
is an empty string.
>
> But I see that value inserted is "NULL".
> Therefore I try to use an 'indicator' variable (indicator=0)
> but I got the same result ("NULL").
>
> For backward compatibility I need to execute a select as:
> SELECT * FROM table WHERE my_field="";
Gianluca wrote:
> I'm using 'char' type host variabile to insert data into a VARCHAR(20,0).
>
> I do the following:
>
> char x[21];
char data types are null if they have a null in
position 0. So when then esql library takes the character
data and converts it to a varchar it will be null, because
that is what the original data type indicated.
I believe you could try using a fixchar. A fixchar does not
recognize the null in the first position as null data.
I generally do this with the sqlda where I set the type to VARCHAR,
the length to 0 and the indicator to not-null.
Hope this helps,
John
> strcpy(x,"");
>
> But I see that value inserted is "NULL".
> Therefore I try to use an 'indicator' variable (indicator=0)
> but I got the same result ("NULL").
>
> For backward compatibility I need to execute a select as:
> SELECT * FROM table WHERE my_field="";