Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Stephen T. on January 17, 2014, 09:50:17 am



Title: NVL, || and edit masks
Post by: Stephen T. 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?


Title: Re: NVL, || and edit masks
Post by: Rene S. 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:   :
~       


Title: Re: NVL, || and edit masks
Post by: Stephen T. 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