DecimalToDecimal Syntax

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
gagan8877
Premium Member
Premium Member
Posts: 77
Joined: Mon Jun 19, 2006 1:30 pm

DecimalToDecimal Syntax

Post by gagan8877 »

Hi

I am have a varchar(50) field:

Source Value Example: 00000000000100000. (it has a decimal at the end wihout any digits after the decimal)

Needed value at traget: 100000.00

Source and target both need to be varchar(50) data type.

I tried to do the folowing:

Trim(DecimalToString(DecimalToDecimal(StringToDecimal(Trim(To_Create_Objs.Value_D)),2)), "0","L")

1. Trim spaces
2. Convert String to Decimal - this gives 0000000000000000000000100000.0000000000
3. Convert Decimal to Decimal to retain Scale of 2 (places after the decimal) - this fails
4. Convert Decimal back to String for triming zeros and for business requirements
5. Trim leading zeros from string

I tried this syntax of DecimalToDecimal Based on the folloing:

viewtopic.php?t=103441&highlight=decimaltodecimal

But it fails with

APT_CombinedOperatorController(2),0: Caught exception from runLocally(): APT_ParseError: Parsing parameters "2" for conversion "decimal=decimal_from_decimal(decimal)": Unexpected input "2" found at beginning of conversion args.
Operator signalled one or more errors.

I do not have the orchestrate manual and Parallel Dev Guide 7.5 does not have complete syntax or an example for DecimalToDecimal, it only lists the arguments, so if someone can guide me, I will be thankful.

Thanks
Gary
"A journey of a thousand miles, begins with one step"
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

It is because your trying to fit a decimal number into a varchar field. It will not work. You need to do StringToDecimal() to fix the lenth and precision and then use DecimalToString() to convert it back to varchar.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gagan8877
Premium Member
Premium Member
Posts: 77
Joined: Mon Jun 19, 2006 1:30 pm

DecimalToDecimal

Post by gagan8877 »

Can u specify scale in StringToDecimal()? If yes, can u please tell me the complete syntax?

Thanks

DSguru2B wrote:It is because your trying to fit a decimal number into a varchar field. It will not work. You need to do StringToDecimal() to fix the lenth and precision and then use DecimalToString() to convert it back to varchar.
Gary
"A journey of a thousand miles, begins with one step"
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Precision is the length of the field and scale is the numbers after the decimal. For exact syntax, check DS help for "Parallel Job Functions" or search here.
Last edited by DSguru2B on Thu Jun 21, 2007 12:59 pm, edited 1 time in total.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gagan8877
Premium Member
Premium Member
Posts: 77
Joined: Mon Jun 19, 2006 1:30 pm

decimal (p, s)

Post by gagan8877 »

Dear Mr. Guru To Be

I respectfully would like to state that I am no guru but I do know what is scale :D The statement decimal (p, s) with p as precision and s as scale represents a decimal number with up to p digits and s of them will be on the right of the decimal point. I already stated above that I did not find much in the Parallel Job Dev Guide and thats why I posted it here after searching for "DecimalToDecimal". So if u can help me with the syntax of the stmt without going into Decimal Precision and Scale that would be awesome.

DSguru2B wrote:Scale is the length of the field and prcision is the numbers after the decimal. For exact syntax, check DS help for "Parallel Job Functions" or search here.
DSguru2B wrote:Scale is the length of the field and prcision is the numbers after the decimal. For exact syntax, check DS help for "Parallel Job Functions" or search here.
Gary
"A journey of a thousand miles, begins with one step"
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Can you have input coming in with a valid scale (00010002.2) ?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gagan8877
Premium Member
Premium Member
Posts: 77
Joined: Mon Jun 19, 2006 1:30 pm

Valid Scale

Post by gagan8877 »

So what should be the valid argument in the DecimalToDecimal function?
Thanks
DSguru2B wrote:Can you have input coming in with a valid scale (00010002.2) ?
Gary
"A journey of a thousand miles, begins with one step"
Post Reply