Remove $ and brackets in numeric feild

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
srinath0253
Participant
Posts: 45
Joined: Sat May 08, 2010 11:07 pm
Location: banglore

Remove $ and brackets in numeric feild

Post by srinath0253 »

Hi,

Im receiving input as text file.
Input: text File
TRANSACTION_AMOUNT(varchar)
($30.12)
$(30.12)
$30.12
30.12

Output: Netezza Table
TRANSACTION_AMOUNT(double precision)
-30.12
-30.12
30.12
30.12

Conditions: 1. If column contains brackets, output should be negative. Else positive.
2. $ symbol and brackets should be removed in output

Logic(which i tried):

Code: Select all

If Count(l1.TRANSACTION_AMOUNT, "(")  > 0 Then  StringToDecimal(Convert("()$", "", l1.TRANSACTION_AMOUNT)) * -1 Else   StringToDecimal(Convert("()$", "", l1.TRANSACTION_AMOUNT))
Result: im getting null values. Request your advice/suggestion.
Srinath
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

StringToDecimal(Convert("()$", "-", InLink.TRANSACTION_AMOUNT))
Each "(" is converted to "-", each ")" is converted to "" (removed), and each "$" is converted to "" (removed).
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 »

To quote an old version of a recent movie: "Clever girl!" :)

Not seeing what is wrong with the original code as posted, however.
-craig

"You can never have too many knives" -- Logan Nine Fingers
srinath0253
Participant
Posts: 45
Joined: Sat May 08, 2010 11:07 pm
Location: banglore

Post by srinath0253 »

Hi Ray,

Can you post the code for public. Im not premium user.
Srinath
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

When you are getting null values are you getting any warning or info message from transformer which ends with something like "Use Default value" ? I think you have spaces etc in data which is causing it to default which converting from varchar to decimal.

Try using IsValid() to find if the result you are getting is decimal and send the details using varchar field to peek to see if you are getting correct result from the derivation.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

srinath0253 wrote:Hi Ray,

Can you post the code for public. Im not premium user.
Hi Srinath,

Can you become a premium member? This is the funding mechanism that keeps DSXchange alive.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
srinath0253
Participant
Posts: 45
Joined: Sat May 08, 2010 11:07 pm
Location: banglore

Post by srinath0253 »

Hi All,

In target, we have double precision. i changed to decimal. Now my code is working. Thanks.

Ray, i will become premium member but not now. :)

Im closing the ticket.
Srinath
Post Reply