position 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
sainath
Premium Member
Premium Member
Posts: 138
Joined: Fri Nov 19, 2004 3:57 pm

position string

Post by sainath »

Hi
I have a string length of 288 characters.
I have some conditions like if position in string[122,125] = 'xyz'
then statement 1 else statement 2.

my question is can we sue incolumn.[122,125] tp return string
at this position.
thks
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You will always get back a string, unless the value is a NULL, you'll get a NULL. If the value is shorter in length than your position, you will get blank (you know quote-quote ""). Since you're using it in an If-Then-Else, you need to consider handling the NULL condition, which you're not.

You're also not insuring only 3 characters are returned because 122,125 means 125 characters returned. If the string is shorter than that, you won't get any padded characters. But, if there's extra values then you'll never get just "xyz".

Consider:

Code: Select all

If ISNULL(string) Then NullResult Else If string[125,1] # "" Then TooLongResult Else If string[122,3]="xyz" Then ThatResult Else DefaultResult
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
sainath wrote:hi
Thanks for your quick reply .
This string cannot be null.

my quesition
position string[123 through 125] including decimals is numeric or ='n/a'
then return the string .
how can me do in datastage.
thks
What ken said is that you can use link.col[122,3] to extract the 122nd - 125th characters of any string (if they exist) then you can compare that string using the If ... Then ... Else syntax to apply your logic.
You may also use any DS basic function like Num() to determine if the string you got is numeric.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

<pedantry>
Character positions 122 through 125 total four characters. Therefore the second argument to substring needs to be 4.

And this will never be equal to "xyz" - a three character string can never be equal to a four character string.
</pedantry>
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply