home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / informix / 3089 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  2.0 KB

  1. Path: sparky!uunet!ukma!gatech!swrinde!emory!emory!not-for-mail
  2. From: promdist!bill@pds.com (Bill Foote)
  3. Newsgroups: comp.databases.informix
  4. Subject: Re: How To Distinguish Null Values in UNLOAD ??
  5. Date: 28 Jan 1993 20:53:20 -0500
  6. Organization: Mailing List Gateway
  7. Lines: 50
  8. Sender: walt@mathcs.emory.edu
  9. Distribution: world
  10. Message-ID: <1ka2mgINNpim@emory.mathcs.emory.edu>
  11. Reply-To: promdist!bill@pds.com (Bill Foote)
  12. NNTP-Posting-Host: emory.mathcs.emory.edu
  13. X-Informix-List-ID: <list.1834>
  14.  
  15. >     Hi gurus,
  16.  
  17. Well, I think that I had my "guru" license suspended when I didn't know
  18. about sqlca.sqlerrd[1], but I'll give it a shot!   :-)
  19. >     I need to dump data from an Informix 2.10 database into an ASCII file. 
  20. > Fine. No problem. But, the program which uses the ASCII file needs to know 
  21. > which values are NULL. The straight UNLOAD statement does not seem to 
  22. > provide any way to distinguish a NULL value in a column from a value which
  23. > has 4 spaces. 
  24.  
  25. Yes, it does.
  26.  
  27. > In either case, the output ASCII is a bunch of blanks.
  28.  
  29. No:  For a null value, the output is a _zero-length_ string, and for a
  30. non-null value it isn't.  A text field that contains all blanks is output
  31. as a string of length one containing a blank.
  32.  
  33. To illustrate, running this bit of sql:
  34.  
  35.     create table test(x serial, a char(10), b char(10) not null);
  36.     insert into test (b) values ("hi");
  37.     insert into test (b) values (" ");
  38.     insert into test (b) values ("");
  39.     unload to "/tmp/test" select * from test
  40.     
  41.     (i.e. x isn't null, a is, and b isn't)
  42.  
  43. produces the following in /tmp/test:
  44.  
  45.     1||hi|
  46.     2|| |
  47.     3|| |
  48.  
  49. Notice that the blank, non-null text fields are of length 1, and the
  50. null text fields are of zero length.
  51.  
  52. The way Informix does it is better than putting a '.' in the ASCII file
  53. for null values:  There is no way a non-null field can produce the same
  54. output as a null field, regardless of contents.
  55.  
  56. I assume that Informix also outputs a zero-length string for a null value of
  57. any other type.
  58.  
  59. -- 
  60. Bill Foote                        bill@pds.com
  61. MIS Director                        uunet!promdist!bill
  62. PDS Corp, Los Angeles, CA  USA
  63.