Re: insert empty strings in ESQL/C
Posted in 1998
Thomas J. Girsch wrote: > > 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! Nope. In ESQL/C you can insert any garbage you want into a char column. I know my predecessor designed a database with 31 prices encoded as either scaled integers or smallfloats packed into a single 128 character column. Notice the extra four bytes? That's because the first byte CANNOT be null or the engine interprets the entire column as null (that is how Informix indicates a NULL char string on disk just like it uses MIN_LONG for an integer NULL ever notice the value range for Informix integers?) so he forced the first byte to all 1 bits, the remaining 3 bytes to maintain data alignment for the packed integers. Once the string with a lead null is accepted by the engine (and it will be) it is interpreted as a NULL column on retrieval. Sorry you are just incorrect. This has been the way Informix char columns have worked for the entire 17 years I've been using the products. Art S. Kagel