Re: insert empty strings in ESQL/C
Posted in 1998
Actually, I don't believe that inserting a string containing '\\0' will result in a NULL; it should insert a space. The only way to insert a null, that I'm aware of, is to set an indicator to -1 and insert using the indicator explicitly. (Unless, of course, the field is non-char, in which case inserting a space translates to null). At least, that's how it used to be in the 7.1 days. I know, because there were times when I WANTED to insert a null, and doing so was a pain in the rear! Art S. Kagel wrote in message <36421615.641D@bloomberg.net>... >ProzessDV wrote: >> >> OWS 7.22 on SCO UNIX, embedded SQL: >> >> How can I insert an empty string, stored in a hostvariable (hostvar = "\\0"), >> into a column without getting a NULL value as a result as I have got so before? > >Just insert a string containing a single space. The engine assumes >that any string with a NULL first character is a NULL string. When >you store a string that contains a single space into the database it >will be expanded to space filled and returned as an empty, but non-null >string. Except for varchars Informix allways space fills strings >anyway so inserting a single space is just a bit faster way of storing >and all blank or empty string. > >If you fetch that row back into a host variable declared as type >'string' you will get a normal "C" Null string (ie string[0] = NULL) >but an indicator on the column will not show the column as being NULL. > >Art S. Kagel