How to set the stage variable within a routine?
Moderators: chulett, rschirm, roy
How to set the stage variable within a routine?
How can I refer to a stage variable within a routine? What I am trying to do is set a stage variable based on certain conditions tested on the input columns.
You don't set one in a routine. If you need to refer to it in a routine, pass it in as one of the arguments. You sould be able to set the Stage variable by simply testing for your 'certain conditions' in the derivation and then set the value based on the outcome of those tests in much the same fashion that you would for any other field coming out of a Transform.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
This is what I am trying to achieve
If InField1 = 0 then
StageVar = KeyMgtGetNextValue AND OutField1 = StageVar
Else
OutField1 = StageVar
This topic was recently discussed in
viewtopic.php?t=86271
wherein it was suggested that a function can be written to update the stage variable. That is exactly what I am trying to do.
Sorry for not being clearer the first time.
If InField1 = 0 then
StageVar = KeyMgtGetNextValue AND OutField1 = StageVar
Else
OutField1 = StageVar
This topic was recently discussed in
viewtopic.php?t=86271
wherein it was suggested that a function can be written to update the stage variable. That is exactly what I am trying to do.
Sorry for not being clearer the first time.
Why not just use your basic derivation for the Stage variable itself and then always populate Outfield1 with the Stage variable? Use:
in the derivation of the StageVar, and then drag it down to the derivation of the Outfield1 column.
Code: Select all
If InField1 = 0 then KeyMgtGetNextValue Else StageVar
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
That elegant solution is really spoiling me... I am back here again looking for help.
Expanding the previous problem, *before* incrementing the stage variable, I want to save the the current value of the stage variable into another stage variable. Is this possible?
e.g. I have one stage variable, lets say stagevar1 of which the derivation is
stagevar1 = (if infield1 = 0 then KeyMgtNextValue else infield1 )
Now I want to use another, which is stagevar2 which should hold the value before updating the field,
stagevar2 = stagevar1
I want this assignment happen before the derivation for stagevar2 happens. I declared the stagevar2 before stagevar1, but didnt help.
TIA,
Expanding the previous problem, *before* incrementing the stage variable, I want to save the the current value of the stage variable into another stage variable. Is this possible?
e.g. I have one stage variable, lets say stagevar1 of which the derivation is
stagevar1 = (if infield1 = 0 then KeyMgtNextValue else infield1 )
Now I want to use another, which is stagevar2 which should hold the value before updating the field,
stagevar2 = stagevar1
I want this assignment happen before the derivation for stagevar2 happens. I declared the stagevar2 before stagevar1, but didnt help.
TIA,
It sounds like it should have worked just fine as the Stage Variables are evaluated in order from top to bottom. It is a very common methodology to do exactly the kind of thing you are doing to check for changes, like changing groups in ordered data for instance.
An issue might be what you put for the initial values when you declared both of them. What happens on the very first row, what is the 'old' value of Stagevar1 that is being put into Stagevar2?
An issue might be what you put for the initial values when you declared both of them. What happens on the very first row, what is the 'old' value of Stagevar1 that is being put into Stagevar2?
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers