Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: NVL, || and edit masks  (Read 7499 times)
Stephen T.
Posts: 114


« on: January 17, 2014, 09:50:17 am »


I am aware that using || when a null variable is involved can end up with the resultant variable being null.
So I want to use NVL in conjunction with || to ensure that the resultant variable isn't nulled.
However, it seems that 'edited' null values do not contain null.

IE
DEFINE l_date                       DATE
INITIALIZE l_date                   TO NULL

CALL FGL_WINMESSAGE('ERROR',NVL(l_date,'NULL')||' Is NULL?','stop')
CALL FGL_WINMESSAGE('ERROR',NVL(l_date USING 'dd mmm yyyy','NULL')||' Is NULL?','stop')
CALL FGL_WINMESSAGE('ERROR',l_date||'Is NULL?','stop')

The question is that is this behaviour likely to change and am I then safe in using NVL on edited and non edited variables?
Rene S.
Four Js
Posts: 111


« Reply #1 on: January 17, 2014, 10:20:16 am »

Hello,
the operator USING does not return NULL if the number/date parameter is NULL. The operator USING returns a string filled with blanks in that case. The reason is simple: the operator USING returns always a string with a "none clipped" fixed length (an exception is the '<' placeholder).

Code
  1. MAIN
  2.    DEFINE n  INT
  3.    DEFINE d  DATE
  4.    INITIALIZE n, d TO NULL
  5.  
  6.    DISPLAY "date:", d USING "dd mmm yyyy",":"
  7.    DISPLAY "number:", n USING "###",":"
  8. END MAIN

The output is:
date:           :
number:   :
~       
Stephen T.
Posts: 114


« Reply #2 on: January 17, 2014, 10:42:17 am »

Rene,
That is roughly what I saw in the tests - I'm ok that the messages either then containing 'blanks' or the word 'NULL' - as the issue was preventing completely blank messages appearing.

Thanks
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines