Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the '*Expression Type:' field, select character.  In the length field, enter 4.  In the 'Expression Text', enter the phase: '

      substr (NATIONAL_ID, 6, 4)

'(no quotes) - this selects four bytes of the NATIONAL_ID, starting in column 6.  You may type in the field name (don't forget the prefix) or press the 'Add Field' link to search for the field.  Press 'OK' when you are done.  Remember to use the field/expression in your report.    

...

Decode

What Expression Does:

This allows the query to convert a database value to something more meaningful.  For instance, if the query needs to display the class schedule with days of the weeks rather than a 'Y' or 'N' flag.

 

The following images illustrated calculation of date using Expression:

In the '*Expression Type:' field, select character.  In the length field, enter 414, to allow two bytes for each day of the week (7 x 2).  In the 'Expression Text', enter the phase:

       decode (E.MON, 'Y', 'Mo') || decode (E.TUES, 'Y', 'Tu') || decode (E.WED, 'Y', 'We') || decode (E.THURS, 'Y', 'Th') || decode (E.FRI, 'Y', 'Fr') || decode (E.SAT, 'Y', 'Sa') || decode (E.SUN, 'Y', 'Su')

 - this converts the 'Y' value into a day of the week.  The 'N' value is ignored.  The '||' (double bar) is the concatenate symbol ' substr (NATIONAL_ID, 6, 4) '(no quotes) - this selects four bytes of the NATIONAL_ID, starting in column 6.  You may type in the field name (don't forget the prefix) or press the 'Add Field' link to search for the field.  Press 'OK' when you are done.  Remember to use the field/expression in your report.  So instead of seven columns with 'Y' or 'N', the query will print something like 'MoWeFr'.