Use the "Position" function to locate the first occurrence of a character (or character string) within a field (the equivalent of the "InStr" function in Access). The function will return the position number of the character within the field.

Syntax:

POSITION ('<character>' IN <field name>)


Example: find the hyphen in the field po_line_number from the table po_receiving_history (alias prh)

POSITION ('-' IN prh.po_line_number)


Use the POSITION function in combination with the SUBSTRING function to parse out the po_number from the po_line_number:

substring (prh.po_line_number, 1, position ('-' in prh.po_line_number)-1)


  • No labels