null values / AS400
Whittall, Conrad
Conrad.Whittall@Cognos.COM
Thu, 8 Aug 2002 12:24:52 -0400
Its been quite a while since I used PowerHouse on an AS/400, and so I can't
be sure that the technique that I (and many others) have used on other
platforms to manipulate non-printable characters will work on that platform.
However, in the ASCII collating sequence NULL has an internal value of zero,
just as the ESCAPE character has an internal value of 27. So, assuming that
NULL in EBCDIC also has an internal value of zero, you might try the
following:
DEFINE null_value INTEGER SIZE 2 = 0
; It is important to use SIZE 2 (not *2) as this ensures that two
; bytes of storage are used for the internal representation, so
; resulting in a string two bytes in length when the CHARACTERS
; function is used...
DEFINE null_char CHARACTER*1 = SUBSTRING(CHARACTERS(null_value),2,1)
Then assign "null_char" to whichever field you wish to contain NULL.
Note that while the result of the CHARACTERS function in this case will be a
two-byte string, where each byte has a binary value of zero, some hardware
architectures are "big-endian" and others are "little-endian". So using this
technique for any other (non-zero) value will require that you know which
"endian" orientation your hardware uses, so that you know whether to take
the first byte or the second byte of the resulting two-byte string to get
the character that you're after. You can always determine this by first
trying out the technique on a printable character, such as the letter "A".
Hope I got the AS/400-specific bits right...but I'm sure you get the idea.
Best regards,
Conrad
Conrad Whittall
e-Learning Architect, Global Education Services
Cognos Incorporated, 3755 Riverside Drive, Ottawa, Ontario, K1G 4K9, Canada
==================================================
This message may contain privileged and/or confidential information. If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender
promptly by e-mail that you have done so. Thank you.