Taking apart a VarBinary field

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
patonp
Premium Member
Premium Member
Posts: 110
Joined: Thu Mar 11, 2004 7:59 am
Location: Toronto, ON

Taking apart a VarBinary field

Post by patonp »

Quick question here...

If I want to extract part of a varchar field, I use the following syntax:

field_name[4,7]

In this case, the 7 characters beginning at the fourth position of file_name will be returned.

How can I accomplish the same thing with a VarBinary data type? (i.e. return 7 bytes of the field beginning at the fourth byte.)
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The same way.
patonp
Premium Member
Premium Member
Posts: 110
Joined: Thu Mar 11, 2004 7:59 am
Location: Toronto, ON

Post by patonp »

I already tried it, but this was the error I received during compilation...
Error in output column derivation expression for column field1 in link LnkInboundData. Invalid conversion requested from a raw to a string.
The actual syntax for the derivation is LnkInboundData.field1[4,7]

The message seems to imply that this functionality is restricted to character-based datatypes.[/quote]
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

It looks like VarBinary has the underlying datatype of "raw" which PX won't let you do anything with (except to determine the length). If the length is short enough, can you just declare this as VarChar in the job and/or do a cast to this datatype in your SQL?
Post Reply