String to Integer

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
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

String to Integer

Post by kumar66 »

Hi All,


I need to convert a string to integer and to compare the converted integer value with a integer .

If the values are same i need to update the status file as 'Y'Else 'N'

i am using the follwoing:

If DSLink71.DETAILROWCOUNT= AsInteger(StringToDecimal(Trim(DSLink71.VALUE,0,'L'))) Then 'Y' Else 'N'

The value of DSLink71.DETAILROWCOUNT is 1000 (integer) and the vlaue of DSLink71.VALUE is 000001000 (String).

The output of the file is 'N'. Please help me in solve this.

Thanks & Regards,
Kumar66
karthikdsexchange
Participant
Posts: 15
Joined: Thu Aug 07, 2008 2:56 am

Re: String to Integer

Post by karthikdsexchange »

Try with the following code.
It works fine for me.
If DSLink3.count = AsInteger(StringToDecimal(TrimLeadingTrailing(DSLink3.value))) Then "Y" Else "N"
Karthik
Make It Work Make It Right Make It Fast
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Alternately do the test first (using IsValid() function) and only attempt the conversion if the validity test succeeds.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
srinivas.g
Participant
Posts: 251
Joined: Mon Jun 09, 2008 5:52 am

Post by srinivas.g »

use this stmt in stage varaible

If (DSLink4.number = AsInteger(StringToDecimal(DSLink4.number1)))Then 'Y' Else 'N'
Srinu Gadipudi
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Hi, in this thread of post I noticed the formula

If DSLink71.DETAILROWCOUNT= AsInteger(StringToDecimal(Trim(DSLink71.VALUE,0,'L'))) Then 'Y' Else 'N'

Why is StringToDecimal and AsInteger needed? How do they work together when converting a string to an integer.
Post Reply