BASIC Routine to Convert datatype

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
krystlecsy
Participant
Posts: 50
Joined: Wed Jul 14, 2004 7:56 am

BASIC Routine to Convert datatype

Post by krystlecsy »

Hi all,

We are using a BASIC Routine to execute a SQL script and retrieve the input and pass into the next job. Now, the problem is the retrieve input is a STRING datatype but I need it to be a NUMBER datatype instead. Is there anyway to convert the input from STRING to NUMBER in the Basic Routine?

I have tried to Ans = Num(Input) but it assigns 0 to it.

Help!!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The Num() function checks to see if something is numeric or not... interesting that the answer it returns for you is 0, aka false. :?

In BASIC, doing math on a string does an implicit conversion so the typical trick is to multiply the field by 1.

Not sure how well this all plays out in a Parallel job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
I don't think you can effect the type of the returned Ans variable like that,
However you can try declaring it in your routine as integer and try to see if it helps (this is a long shot).
Other then that the only thing you can probably do is use modify or transformer stage to convert that string to a number or the other way around (convert the number you have to a string to match the returned data typr from your basic routine.

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 »

BASIC doesn't have data types, so the answer is properly no. Pass the value as string into your parallel job and convert it there.
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