Numeric Loop Value

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
Ahimsa
Premium Member
Premium Member
Posts: 78
Joined: Fri Aug 18, 2006 11:05 pm

Numeric Loop Value

Post by Ahimsa »

I have a numeric loop. Loop end value is based on the number value in the .txt file
I have a execute command stage to read the value from the .txt file.
Execute command stage is having line this - cat test.txt
e.g. if this file is having the number 10, loop should be executed for 10 times.
in the loop, I am using the expresion - Convert(getCountValue.$CommandOutput,@FM,1)

but I am getting error saying not numeric value.

Would appreciate your suggestions.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your Convert() syntax is wrong, looks more like Field() syntax.

Code: Select all

Convert(@FM,"",getCountValue.$CommandOutput)
Assuming you want to strip any field marks from the output.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Ahimsa
Premium Member
Premium Member
Posts: 78
Joined: Fri Aug 18, 2006 11:05 pm

Post by Ahimsa »

I tried it and I am getting error -

Loop final value not numeric (Convert(@FM,"",2) - cannot execute
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sounds like you're doing this directly in the Loop Definition "To:" field and, while this can work in a Trigger expression, you cannot do it directly in the Loop Definition. You'd either need to send this in as a job parameter to the Sequence job and use the job parameter in the Start Loop stage or use a Routine Activity rather than the Execute Command stage.

Do basically the same thing in a routine using DSExecute: cat the file and then convert() to strip the field marks before passing back the count as the Answer. Then you can reference that in the Start Loop:

Code: Select all

#RoutineActivityStageName.$ReturnValue#
-craig

"You can never have too many knives" -- Logan Nine Fingers
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Numeric Loop Value

Post by SURA »

Ahimsa wrote:I have a numeric loop. Loop end value is based on the number value in the .txt file
I have a execute command stage to read the value from the .txt file.
Execute command stage is having line this - cat test.txt
e.g. if this file is having the number 10, loop should be executed for 10 times.
in the loop, I am using the expresion - Convert(getCountValue.$CommandOutput,@FM,1)

but I am getting error saying not numeric value.

Would appreciate your suggestions.
You can check this one.

1) Execute Command (cat file name); In the triggersUse this
Trim(Convert(@FM : @VM : @SM : @TM : @IM : Char(10) : Char(13) : Char(9), ' ', StageName.$CommandOutput))<>''
2) In the start loop you can always use 1 from and StageName.$CommandOutput is for To.


Thanks
Ram
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Did you 'check' this suggestion? Putting an expression in a trigger isn't going to help as you can't actually change the $CommandOutput value from there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Ahimsa
Premium Member
Premium Member
Posts: 78
Joined: Fri Aug 18, 2006 11:05 pm

Post by Ahimsa »

Trigger is not changing the value of command output. So still the same problem.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... with still the same answer I posted yesterday. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply