Re: NULL value
Posted in 1998
Art S. Kagel wrote: > julie lin wrote: > > > > On Tue, 20 Oct 1998 18:22:23 +0100, Peter Lancashire > > <Peter.Lancashire.PL1@bayer.co.uk> wrote: > > > > Helmut Leininger wrote: > > > > > > julie lin wrote: > [Lots of interchange SMIPPED] > > > > >Also, I bet your WHERE clause looks like this: > > > > >WHERE mycol = ? > > > > >whereas what you should write is: > > > > >WHERE mycol IS NULL > > > > I know " WHERE mycol IS NULL " will work , but for some reason, > > it'll be easier for me for using only dynamic SELECT statements (has > > replacable parameters "?" in the where condition), I just wonder why I > > can insert NULL data by using the following dynamic INSERT statement ? > > > [SNIP] > > EXEC SQL execute ss using descriptor bind; > > If you are using descriptors you can set the indicator field (sqlind) > to -1 and the engine will interpret your replaceable parameter as NULL. > This is the correct way to insert a NULL, even into a character column, > also. What actually happens when you insert the explicit NULL string > is that the engine thinks it is inserting a valid string, it does not > parse the string at all to see if it is valid at insert time, but at > fetch time the NULL first byte causes the engine to interpret the > column as NULL and to set the indicator in the descriptor/sqlda. > > Art S. Kagel In addition, setting sqlind is a little tricky because it does not take 1 or 0, but a pointer to one or zero. short ind_null = -1; short ind_notnull = 0; colp->sqlind = &ind_null; ---jmiller John Miller