Is there a function to convert a string into a number ?
Moderators: chulett, rschirm, roy
-
- Charter Member
- Posts: 88
- Joined: Tue Jan 13, 2004 3:07 pm
Is there a function to convert a string into a number ?
I need to convert a string into a number. This is needed for performing a mod operation.
Hi,
Basically DS is type free, meaning that if you take a string and put it in a phrase of numeric meaning it will work if you enshure that it is numeric castable (a number in fact) in a transformer for example.
though types are checked when you read/write data from/into you sources/targets.
IHTH
Basically DS is type free, meaning that if you take a string and put it in a phrase of numeric meaning it will work if you enshure that it is numeric castable (a number in fact) in a transformer for example.
though types are checked when you read/write data from/into you sources/targets.
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
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
not necessarily true
I wrote a VAL function a few years back.
It will convert things like "1.244E10", "$5767.88" and other non numeric fields to number.
It will convert things like "1.244E10", "$5767.88" and other non numeric fields to number.
Re: Is there a function to convert a string into a number ?
Therefore, you are asking if you need to convert from a string to an integer. Not necessary -- as others have said, DataStage is MOSTLY type-independent. Just lets the mod function rip.Inquisitive wrote:I need to convert a string into a number. This is needed for performing a mod operation.
Naturally, you need to ensure that your data is validated as an integer in advance.
However, if you want a decimal values, just use StringToDecimal().
-T.J.
Developer of DataStage Parallel Engine (Orchestrate).
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
If you're using a BASIC Transformer stage (or are in a server job), you can use a BASIC expression. The easiest way is to perform some arithmetic. But you have to be certain that what you're beginning with can be regarded as numeric.
The Iconv function will remove thousands delimiters and currency symbol. It will also round to the indicated number of decimal places and NOT return the decimal place holder character. Find out all about the "MD" conversion in on-line help from Designer or Manager.
Code: Select all
If Num(inlink.column) Then Iconv(inlink.column,"MD0") Else 0
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Is there a function to convert a string into a number ?
PX is not freely-typed b/c it doesn't operate on DS's Basic engine. It uses a separate c-based engine.
I don't know the answer to the original question, but if someone has the APT_Ref cards, could they be kind enough to see if there is a str_to_num function for the APT_String class?
Thanks,
BP
I don't know the answer to the original question, but if someone has the APT_Ref cards, could they be kind enough to see if there is a str_to_num function for the APT_String class?
Thanks,
BP
Re: Is there a function to convert a string into a number ?
There is an "asInteger(APT_Int32, APT_Status)" within APT_String class.bigpoppa wrote:I don't know the answer to the original question, but if someone has the APT_Ref cards, could they be kind enough to see if there is a str_to_num function for the APT_String class?
However, what the person would want is a APT_FieldConversion - there's tons of conversion options in it.
This is referring to Orchestrate HTML 6.0 version.
-T.J.
Developer of DataStage Parallel Engine (Orchestrate).