Data Transformation Engine Functions and Expressions Reference Guide

Chapter 3 - Function Reference UNPACK
Functions and Expressions Reference Guide
216
UNPACK
The UNPACK function converts text that can be interpreted as a packed decimal
number to a signed integer item.
The sign values for packed data are as follows:
C for positive (+)
D for negative (-)
F for unsigned, which is read as positive
Syntax
UNPACK ( single-fixed-size-text-expression )
Meaning
UNPACK ( text_to_unpack )
Returns
This function returns a single-signed-integer.
Returns a signed integer representing the value text_to_unpack, which is a
packed decimal number. If the text_to_unpack cannot be interpreted as a valid
packed decimal,
UNPACK evaluates to NONE.
In a packed decimal number, each half-byte is a digit, except for the last half-
byte of the rightmost byte, which contains a sign.
Examples
UNPACK ( "1L" ) returns 314
The ASCII string “1L”, in hex, is 31 4C, which, when interpreted as a packed
number, results in (positive) 314. This example returns the value “+314”.
The hexadecimal representation of the value "1L" is x‘14C’, where C in the
rightmost half-byte represents a positive sign.
UNPACK ( UnitPrice ) / 100 * QuantityOrdered
UnitPrice is unpacked and divided by 100 (to convert it from an integer to a
number with two decimal places) and then multiplied by the
QuantityOrdered.