Page 1 of 1

stringtodecimal

Posted: Sat Jul 26, 2008 10:36 pm
by mrvsr
Hi

I am trying to convert a string1 varchat(256) = 010.0009898878999890 to field1 decimal(20,20) .I used stringtodecimal(string1,"ceil") function for field1 derivation. getting 100e23 when trying to see in the sequential file(even using vi editor or cat) or dataset. I think I can resolve this by taking only Left 10 digits from string after decimal point but I would like to know the efficient way to convert string to decimal in this situation please help in solving this problem by giving the complete syntaxes of functions we need to use.

Thanks

Posted: Sun Jul 27, 2008 5:49 pm
by vmcburney
Here is what is happening: you are converting from varchar to decimal, you are then writing to a sequential file stage which is implicitely converting you decimal back to varchar. It's using a default conversion for this that you might be able to alter inside the format tab of the sequential file stage. But why convert varchar to decimal to varchar? Why not just leave it as varchar? If you do your varchar to decimal conversion and write it to a Peek stage you might get a better idea of how the conversion worked. The sequential file stage is a poor way to take a look at parallel data.

Re: stringtodecimal

Posted: Sun Jul 27, 2008 9:20 pm
by getsatish_gk
Hi mrvsr,

Did u tried without any conversion i.e, don't specify any conversion rule
and make ur target column to decimal(x,y) and ajust the y according to ur req.

but, yes if you want to do some ceil or float then conversion is req.

mrvsr wrote:Hi

I am trying to convert a string1 varchat(256) = 010.0009898878999890 to field1 decimal(20,20) .I used stringtodecimal(string1,"ceil") function for field1 derivation. getting 100e23 when trying to see in the sequential file(even using vi editor or cat) or dataset. I think I can resolve this by taking only Left 10 digits from string after decimal point but I would like to know the efficient way to convert string to decimal in this situation please help in solving this problem by giving the complete syntaxes of functions we need to use.

Thanks

Posted: Sun Jul 27, 2008 9:31 pm
by ray.wurlod
Is this a server job (as marked) or a parallel job (as posted)?

Re: stringtodecimal

Posted: Thu Jul 31, 2008 1:59 pm
by mrvsr
Hi Ray,

How are you doing.

It is a paralled job.

I have my job like this

in seq stage
Col1 Varchar(256)

0.0
0001.09130000000000000000000000000000012
9999999999999999999999.99999999999999999999999999999999
123456.1234567


Tranformer
Out col1 Decimal(10,10)
col1 = StringToDecimal(col1)

Peekstage out put
Peek_5,0: col1: .0000000000
Peek_5,0: col1: .0000000000
Peek_5,0: col1: .0000000000
Peek_5,0: col1: .0000000000

Changed Out col1 datatype
Out col1 Double 10,10

PeekStage out put
Peek_5,0: col1:0
Peek_5,0: col1:1.0913
Peek_5,0: col1:1e+22
Peek_5,0: col1:123456


Please let me know how can I write into db2 table the same input data
like 9(40).9(40) format without loosing it.

Thanks

Re: stringtodecimal

Posted: Thu Jul 31, 2008 4:11 pm
by mrvsr
I got it Thanks