home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / database / sybase / 600 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  1.2 KB

  1. Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!mailgzrz.TU-Berlin.DE!news.netmbx.de!Germany.EU.net!mcsun!sunic!seunet!enea!sommar
  2. From: sommar@enea.se (Erland Sommarskog)
  3. Newsgroups: comp.databases.sybase
  4. Subject: Fun with isnull
  5. Message-ID: <1993Jan5.173012.9858@enea.se>
  6. Date: 5 Jan 93 17:30:12 GMT
  7. Organization: Enea Data AB
  8. Lines: 29
  9.  
  10. Consider this query:
  11.  
  12.    update nisse
  13.    set s1 = (select sum(v1)
  14.              from pelle p
  15.              where p.k2 = nisse.k2)
  16.  
  17. Which rows do you think it updates? Right, it updates the same rows 
  18. as the select statement covers.
  19.  
  20. Now, consider:
  21.  
  22.    update nisse
  23.    set s1 = (select isnull(sum(v1), 4711)
  24.              from pelle p
  25.              where p.k2 = nisse.k2)
  26.  
  27. Which rows do you think this query updates? The same? Wrong answer.
  28. All rows in nisse. Not a single one saved.
  29.  
  30. Another interesting feature with isnull which is a colleague of mine
  31. have run into, but I haven't been able to reproduce is that it sometimes
  32. returns - NULL!
  33.  
  34. These amusements happened with a 4.2 server on AIX 3.2, and with an
  35. SQL server on OS/2 of some version - probably a fairly old one.
  36. -- 
  37. Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se
  38. Jag gav en k{ck tjeck en check.
  39.