Re: Bug in ESQL/C V9.14?
Posted in 1997
Silvia Behr <behr@es5.siemens.ch> wrote: :Alton B. Coalter wrote: :> :> Silvia Behr wrote: :> > :> > Hi, :> > :> > I think there is a Bug in the product ESQL/C V9.14. :> > Using an hostvariable of the type string to read an empty string in :> > a column of the type char(20), I recieve a string with one space :> > caracter, not an empty string. :> > I'm using a database V7.21. :> > :> > Who can help me? :> :> No one. That's the way it works. This is how a NULL and a non-NULL :> are distinguished. :> :> -/Renegade : :But the column is NOT NULL and I inserted ''. But I read ' '. :If the column is NULL you can test it with the indicators. You have hit on a tiny problem wich exist in most databases. To save space there is no length indicator on a type char column in the database, nor a terminator (like the null byte terminator in C). Informix also have no spesial indicator field in the database for null. They use a special value instead. Informix therefore allways pads all char variables to the right of whatever data you insert with spaces. If you insert a space the whole column contains only spaces. The same is true if you insert an empty string. It's padded with spaces. They could theoretically have put in a null byte terminator if the data was shorter than the columnwith. They do however use the null byte (in the first position only I think) as the indicator for null (unknown value) for a char column, so this isn't possible either. You simply have to live with whatever problems may arise from this. In my case this have never been any problem at all. If it is you may be able to use your own indicator values. A char field can take any data except 0 hex, so you might put in something like 1 hex in the first position. Cludgy yes, but may be possible. I would rething heavily if you realy need to destinguish between an empty string, one containing one or more spaces and one that is set to null. Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org