Advertisement
ExaGridDba

avoid divide by zero error with nullif

Oct 23rd, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.81 KB | None | 0 0
  1. [oracle@stormking cdb12102 SQL]$ cat div0.SQL
  2. SELECT n, 1 / NULLIF ( n, 0 ) rn
  3. FROM
  4. (
  5.         SELECT level - 3 n
  6.         FROM dual
  7.         CONNECT BY level <= 5
  8. )
  9. ORDER BY n
  10. ;
  11.  
  12. quit
  13. [oracle@stormking cdb12102 SQL]$ sqlplus u/u@//stormking:1521/pdbm @ div0.SQL
  14.  
  15. SQL*Plus: Release 12.1.0.2.0 Production ON Sat Oct 24 00:17:44 2015
  16.  
  17. Copyright (c) 1982, 2014, Oracle.  ALL rights reserved.
  18.  
  19. LAST Successful login TIME: Sat Oct 24 2015 00:17:39 -04:00
  20.  
  21. Connected TO:
  22. Oracle DATABASE 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
  23. WITH the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
  24. AND REAL Application Testing options
  25.  
  26.  
  27.          N         RN
  28. ---------- ----------
  29.         -2        -.5
  30.         -1         -1
  31.          0
  32.          1          1
  33.          2         .5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement