home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / database / oracle / 1505 < prev    next >
Encoding:
Internet Message Format  |  1992-09-07  |  2.1 KB

  1. Path: sparky!uunet!uswnvg!nv6.uswnvg.com!mmcgreg
  2. From: mmcgreg@uswnvg.com (Mark McGregor)
  3. Newsgroups: comp.databases.oracle
  4. Subject: Re: Oracle Precompilers and Nulls
  5. Message-ID: <2663@uswnvg.uswnvg.com>
  6. Date: 4 Sep 92 18:41:35 GMT
  7. References: <Bu0zGv.941@mentor.cc.purdue.edu>
  8. Sender: news@uswnvg.uswnvg.com
  9. Distribution: usa
  10. Organization: U S WEST NewVector Group, Inc.
  11. Lines: 45
  12. X-Newsreader: Tin 1.1 PL5
  13.  
  14.  
  15. First, this is not a precompiler "problem".  It is an SQL issue.
  16. The same results are obtained in SQL*Plus if you join two tables
  17. on columns which allow nulls.  The nulls are not evaluated in
  18. a join statement using "=" (as far as I know).  Here are two
  19. possible alternatives.
  20.  
  21. 1.  Nvl( TNAME.CNAME, '?????' ) = Nvl( :hostvar, '?????' )
  22.  
  23.     where ????? is a value of your choice which should NOT be in
  24.     the range of CNAME for this to work properly.  If I use this
  25.     type of command I try to pick some very strange value.  But
  26.     be careful on dates and numbers (especially numbers since there
  27.     are fewer strange values).  I personally would not use this
  28.     construct in very much (if any) production code.  It works fine
  29.     for quick and dirty stuff.
  30.  
  31. 2.  ( ( TNAME.CNAME is NULL And :hostvar is NULL )
  32.     Or
  33.       ( TNAME.CNAME is Not NULL And :hostvar is Not NULL And
  34.         TNAME.CNAME = :hostvar ) )
  35.  
  36.     I often use this construct (or a similar one) to handle optional
  37.     variables on a query.  This should return "matches" on null
  38.     columns (i.e. where both the host variable and table.column are
  39.     NULL).  It does not, however, return stuff is one of the two
  40.     columns is NULL and the other has a value.  There are of course
  41.     ways to do this.
  42.  
  43.     Also, as I'm sure some people will point out, the "TNAME.CNAME is
  44.     Not NULL And..." line is optional.  You could use:
  45.  
  46.     ( ( TNAME.CNAME is NULL And :hostvar is NULL )
  47.     Or
  48.       ( TNAME.CNAME = :hostvar ) )
  49.  
  50. I hope this is of some redeeming value.
  51.  
  52.  
  53. Mark McGregor
  54.  
  55. "Ancient definition of Oracle:  A place where people queried pig livers
  56.  in order to make important decisions.  What a marvelous history for
  57.  a database manager..."
  58.  
  59.