NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle database record EOF for data operations

I am using TestStand 2.0 stepping through SQL records (generated by OpenSQL statement) using the Data Operation object. I use two Data Operations: one to read the current record (and save db values to locals), and one to fetch the next record for the next entry into the loop. My problem is that when I get to the end of the record, an error is generated on the fetch. How can I spin through db records (in Test Stand)until EOF without generating (or properly handling) an error?
0 Kudos
Message 1 of 2
(3,184 Views)
To Temp8675309 -
If the Open SQL Statement step type returns a record set and the number or records is know, you can request that that value be stored in a local variable. See the option on the edit dialog for the step.

If a value is not returned for this, you have to turn on Ignore RunTime Error for the step and add a statement step after it to determine if the error code of the preceeding step is EOF or something else. If something else, you can "throw" the error by causing that step to error. The expressions for the step could be(assuming -10 is the EOF error code):


Statement Step Precondition:

(RunState.PreviousStep.Error.Code < 0) && (RunState.PreviousStep.Error.Code != -10)

Statement Step Expression:

Step.Result.Error.Msg =
RunState.PreviousStep.Error.Msg,
Step.Result.Error.Code = RunState.PreviousStep.Error.Code,
Step.Result.Error.Occurred = RunState.PreviousStep.Error.Occurred

Scott Richardson (NI)
Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 2
(3,184 Views)