stringtodecimal

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
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

stringtodecimal

Post 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
Thanks
MRVSR
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post 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.
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

Re: stringtodecimal

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is this a server job (as marked) or a parallel job (as posted)?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Re: stringtodecimal

Post 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
Thanks
MRVSR
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Re: stringtodecimal

Post by mrvsr »

I got it Thanks
Thanks
MRVSR
Post Reply