Re: null vs. empty string? (the same old story...)
Posted in 1999
when selecting from the database you can identify the fields that have been inserted with "" and those that have null by using select from tabname where length(fieldname) < 1 if you don't want to alter your application to insert the keyword NULL instead of "" , then use the above select statement when getting data. At 03:49 PM 5/21/99 +0200, you wrote: >Sorry to bother you all again with the old "null vs. empty string" issue. >I'm sure this has been discussed in this group over and over again but >searching through the archives and other sources I can't find an answer to >my particular problem: > >Informix handles an empty string and the null value differently, i.e. if I >insert an empty string ('' or "") into a string field then that does not >convert to null. This is fine with me as I would expect that behavior from >any RDBMS. However, I now have to port an application from Oracle and SQL >Base, both of which convert an empty string to null when inserting/updating, >to Informix. This application makes intensive use of inserting an empty >string but actually meaning to insert null. > >Is there any way to force Informix to adapt Oracle's behavior of >interpreting an empty string as null? >If not, are there any suggestions for workarounds? I have thought about >writing triggers that would intercept inserts/updates of an empty string and >instead insert/update null, but that seems kind of awkward (besides, I >wouldn't even know how code such a trigger). > >Any help would be greatly appreciated. > >Cheers >E. >