How to find the length for decimal field

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

How to find the length for decimal field

Post by somu_june »

Hi,

I have a server job. I am having a field "Price" which has decimal (15,2) length and I want to send the records which has decimal(12,2) length to one file and remaining records which is not having length decimal (12,2) to the other file or link.

Can some one help in solving my problem.



Thanks,
Somaraju
somaraju
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Use the Matches operator. Something like

Code: Select all

if in.Col Matches "12N.2N" then "A" else if in.Col Matches "15N.2N" then "B" else "C"
Do the above in a stage variable. For Decimal(12,2) the stage variable will evalute to A. Similarly for Decimal(15,2) it will evalute to "B", for everything else it will be "C".
Use A, B and C in the constraint.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi Dsguru,

I tried with the option matches that you have mentioned. But Iam not able to filter any records with decimal length(12,2) .

In Stage variable I mentioned Stage 1 as variable and in Derivation I mentioned

if Frm_Sort.Price Matches "12N.2N" then "A" else "B"


And in Constraint I mentioned Trim(inColumn.Price) ='A' and the other link Constraint as Trim(inColumn.Price) ='B'

But no records are going to these links


Thanks,
SomaRaju
somaraju
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try the IsValid() function I posted here some time back.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Is the name of your stage variable inColumn.Price ? I doubt it. Say your stage variable is called StgVar, then the constraint for Decimal(12,2) should be

Code: Select all

StgVar = "A"
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
satya1
Participant
Posts: 6
Joined: Mon Apr 30, 2007 4:36 pm

Folder Stage

Post by satya1 »

We Need to load TERADATA table from a stack of files having the same File Layout in a folder (EBCDIC FORMAT) in WIndows Env. Would anyone give us any suggestions ??

Thanks
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi Ray,


If I use a parallel job and IsValid() function . Can you please tell me what arguments do I need to pass in IsValid() function. I tried like this IsValid("decimal", Incolumn.price) but every record is going to that link . I want to filter records whose length is (12,2) to a file .



Thanks,
somaRaju
somaraju
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi DSguru,


I tried with Stage Variable as you mentioned. I gave stage Variable name as

StagVar and in derivation I mentioned as

If Frm_Sort.Price Matches "12N.2N" then "A" else "B"

and in Constraints I mentioned as you said

StgVar = "A" and StgVar = "B"

But every record is going to the StgVar = "B" and not to to StagVar = "A" link


Thanks for helping me ,

SomaRaju
somaraju
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Ok tell me this. For a Decimal value 12.33 coming in, how does it show in the database/dataset? Does it show 12.33 or 000000000012.33 for (12,2)?

You can also try with lenth function.
Len(in.Link) = 14 for (12,2) and
Len(in.Link) = 17 for (15,2).
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi Dsguru,

In sequential file Iam seeing the decimal value as 1234567891.00 for
decimal (12,2) and for Decimal (15,2) Iam seeing as 1234567891234.00 and I tried with Length function but it is giving length to all the fields as 15 whether it is(12,2) or (15,2). I mentioned in input Sequential File a decimal (15,2) and in target Sequential file I created field Length and defined as integer (10) to find the length of each field but all fields are having the same length 15 .


Thanks,
Somaraju.
somaraju
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

My bad. The matches argument is wrong. Please try again with the following.
Try both:

Code: Select all

If Frm_Sort.Price Matches "10N.2N" then "A" else "B" 

OR

Code: Select all

If Frm_Sort.Price Matches " 10N.2N" then "A" else "B" 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi DSguru,


I tried with the code you have mentioned. But no luck, all records are going to StagVar = "B" link and no records or 0 records are going through the StagVar = "A" constraint link




Thanks,
SomaRaju.
somaraju
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is, on this forum, an IsValid() function for server jobs. It is well documented.
Please post parallel job questions on the parallel forum.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And for goodness sakes, if you are going to keep going back and forth on this, post some actual data samples you are seeing. Made up stuff like "I am seeing 1234567891234.00" doesn't help anyone help properly.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Also, specify the decimal as varchar and then take the length. I forgot to mention this when I suggested to go with the Len() function.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply