Select the 4th byte in a String

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

Post by spracht »

Substring operations can be performed using square brackets [start,length].
As a derivation for your stage var you could use:

stagevar=sourcecolumn[4,1].


For other interesting forms to use [] please refer to the documentation.

Regards

Stephan
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A substring based approach only works in bytes if a single-byte character set is in use. Since the OP is in the USA this is a fair, but by no means guaranteed, assumption.
All the substring functions actually work with characters which, in multi-byte character sets, is not the same thing as bytes. Stephan's answer gives you the fourth character from a string. There do exist functions such as BYTE, BYTELEN, BYTETYPE and so on for extracting and identifying specific bytes from a string in a multi-byte character set, but these are largely meaningless for all practical purposes.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Post Reply