Derivation error in Convert function

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
wahi80
Participant
Posts: 214
Joined: Thu Feb 07, 2008 4:37 pm

Derivation error in Convert function

Post by wahi80 »

Hi,

I have the following condition in the derivation stage

Code: Select all

If (DSLink3.Amount>0) Then (if Right(DSLink3.Amount,1)=3 Then Convert(Right(DSLink3.Amount,1),t,DSLink3.Amount) Else DSLink3.Amount) Else "Negative"
But the derivation keeps giving me an error, when I replace the part Convert(Right(DSLink3.Amount,1),C,DSLink3.Amount) with say "DummyVal" the derivation works.

Can anyone point what I'm missing?

Regards
Wah
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Convert(Right(DSLink3.Amount,1),t,DSLink3.Amount)
Is 't' a stageVariable in your transformer? If not, it has to be a string which is supposed to be enclosed in two single quotes. By the by, is your error a compile time error?
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
wahi80
Participant
Posts: 214
Joined: Thu Feb 07, 2008 4:37 pm

Post by wahi80 »

Hi,

The single quote was missing, now the derivation is working fine. Thanks!!
Another doubt is regarding the expression

Code: Select all

If (DSLink3.Amount>0) Then (if Right(DSLink3.Amount,1)=3 Then Convert(Right(DSLink3.Amount,1),'A',DSLink3.Amount) Else DSLink3.Amount) Else "Negative"
I have to do the above check for each trailing character of every amont field in the table. I want to simplify the code so that if there is a change I need to change it in one place only.

I have 15 amount fields.
In server edition I could have used Transforms to break up the derivation and make it simpler.
e.g I could have one transform to get last digit of the amount
Another Transform to do the conversion and so on

But in parallel jobs we cannot use transforms
If I use stage variables I will again have 15 conditions for the 15 fields

Regards
Wah
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

The only thing that comes to my mind is a parallel routine. You can do this by creating a simple parallel routine.
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
Post Reply