Re: Informix datetime type
Posted in 1998
Zhiyong Li wrote:
>
> Anyone can give a good description about Informix datetime type.
> Specifically,
> I have a question about datetime values retrieved from database when the
> value is Null. Even I write a null value to the datetime column, when I
> retrieve it. The
> return value is not null. Anyone knows are there anyway I can enforce this
> behavior?
>
> What I need is that if I update a row with a NULL for the datetime column, I
> would like to have a NULL returned by getTimestamp at Java side.
If you insert NULL the server stores and returns NULL. However, NULL
is returned as out-of-band information in an indicator variable if one
is provided, otherwise there is no direct way to detect a NULL. If
your Java library does not permit indicators you can try depending on
the engine to not modify the current value of a host variable into
which a NULL has been selected. So if you initialize the DATETIME to
NULL and it is still NULL after the FETCH, tada! Otherwise you use
indicators in SQL so:
SELECT a,b,c
INTO var1 indicator ind1, var2 indicator ind2, var3 indicator ind3
ODBC also provides a way of querying the NUL status of a returned
binding.
Art S. Kagel