Increment Counter based on Stage Variable

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
jweir
Participant
Posts: 134
Joined: Wed Aug 04, 2010 12:31 pm

Increment Counter based on Stage Variable

Post by jweir »

Hi all,

I am trying to increase a counter based on a record match. I first initialize the counter to 1. If there is a record match, I want to increase the counter by 1 else set the counter to 1.

For instance, if there are five records matches in a row, the counter would be equal to 5. Below is my code. Currently, the stage variable only increases to 2 and repeats 2 for every record match after that, so it is not increasing after 2. What is causing this?

Code: Select all

If svMatchCheck = 1 Then
(svGroupRecordIdx + 1)	
Else
(svGroupRecordIdx = 1)
I have also tried the below, which results in record matches returning only zero:

Code: Select all

If svMatchCheck = 1 Then
(svGroupRecordIdx = svGroupRecordIdx + 1)	
Else
(svGroupRecordIdx = 1)
Let me know if anyone needs more information.

Thanks in advance.
Jweir

--- If strength were all, tiger would not fear scorpion.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The first code should work if it is the derivation expression for the stage variable svGroupRecordsIdx.

The second code will not work because you have tried to use an assignment statement, but it's actually treated as a Boolean test condition.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jweir
Participant
Posts: 134
Joined: Wed Aug 04, 2010 12:31 pm

Post by jweir »

Thanks for the reply.

Not sure what your exact response was, since I am not a premium member. However, I believe to understand that we cannot use assignment statements within stage variables.

I will try and see if there is a workaround.
Jweir

--- If strength were all, tiger would not fear scorpion.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A derivation is an expression who's derived value is automatically assigned to its associated variable. You cannot do direct assignments in any derivation.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kiran0435
Participant
Posts: 39
Joined: Sun Sep 26, 2010 10:28 pm

Post by kiran0435 »

Use the given expression below. It will work.

If svMatchCheck = 1 Then
(svGroupRecordIdx + 1)
Else
1
Post Reply