Page 1 of 1

DecimalToDecimal conversion in Transformer

Posted: Wed Jan 09, 2008 2:32 pm
by vijayrc
Hi,
Searched for DecimalToDecimal, found few posts, but it isn't clear atleast for me, as I have to do the follwoing and struggling to get the right syntax [Transformer is what i'm using]

Field 1
Input Field : Decimal 12,1
Output Field Decimal 8,1

Field 2
Input Field: Decimal 12,0
Output Field: Decimal 9,0

Thanks,
Vijay

Posted: Wed Jan 09, 2008 5:13 pm
by ray.wurlod
You shouldn't need to do anything.

However DataStage will generate a warning to alert you that you can not fit all known Decimal(12,1) values into a Decimal(9,1) field.

If you know that you will be able to, because none of your Decimal(12,1) values has more than nine significant digits, then why not read the values in the first place as Decimal(9,1) - with a CAST, for example?

Posted: Wed Jan 09, 2008 11:23 pm
by Maveric
If you are sure that the input data will fit into Decimal 8,1 and Decimal 9,0 for fields 1 and 2 respectively, then you can directly map them from source to target. However DataStage will generate a warning. And you can suppress the warning to informational from the Director log.

Posted: Thu Jan 10, 2008 7:44 am
by vijayrc
Maveric wrote:If you are sure that the input data will fit into Decimal 8,1 and Decimal 9,0 for fields 1 and 2 respectively, then you can directly map them from source to target. However DataStage will generate a warning. And you can suppress the warning to informational from the Director log.
Yes..I'm getting Warnings, and I want to avoid those warnings instead of downgrading them to Informational, and hence this attempt.

Implicit conversion from source type "decimal[12,0]" to result type "decimal[9,0]": Possible range limitation.


Tried the following with Modify too, but it generates a warning:
Conversion from source type "decimal[15,2]" to result type "decimal[12,2]": Possible range limitation; rounding requested where no rounding possible.

New_Decimal_Field:Decimal[12,2] = decimal_from_decimal [round_inf] (Old_Decimal_Field)

Old_Decimal_Field is 15,2
New_Decimal_Field is 12,2

Posted: Thu Jan 10, 2008 10:44 am
by ray.wurlod
Add an extra Specification to the Modify stage. This new Specification contains the single word NOWARN.

Posted: Thu Jan 10, 2008 12:28 pm
by vijayrc
ray.wurlod wrote:Add an extra Specification to the Modify stage. This new Specification contains the single word NOWARN. ...
Thanks Ray..That worked w/o a warning. But I have to introduce a Modify just for this in my stream. If you could suggest something in a Transformer, that would be great. I'm still trying on making transforming transformation of this decimal conversion

Posted: Thu Jan 10, 2008 4:05 pm
by ray.wurlod
I am unaware of any mechanism for preventing Transformer stage from generating warnings.

I had assumed, because you said "tried the following with Modify too" that you had a Modify stage in the job. Well, now you do. Leave it there - it doesn't eat much.

Posted: Fri Jan 11, 2008 8:14 am
by vijayrc
ray.wurlod wrote:I am unaware of any mechanism for preventing Transformer stage from generating warnings.

I had assumed, because you said "tried the following with Modify too" that you had a Modify stage in the job ...
Thanks Ray for your input. I just tried having a Modify for this purpose, to eliminate the warning and to see if it works. Now that it works with your suggestion of NOWARN, I would either let it stay there just for warning suppression or go with Message Handler to suppress this warning.

Still hanging on to find a solution with a transformer as I have one along the way in my job stream

Thanks again for all your help inDS community