NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine the number of rows in database and save that result to a local variable?

Solved!
Go to solution

Hello,

 

I'm a newbie in using TestStand, databases and SQL, and now I have faced trouble. I'm using TestStand 2014 (32-bit).

 

I have a need to find the number of rows in a database and save that number to a local variable. I have tried to practise using the Database Step Types provided with TS. I tried using the following in a SQL Statement:

 

Locals.NumberOfRows = ("SELECT COUNT(*) FROM TEST_TABLE")

 

It returns an error: Specified value does not have the expected type. Can my goal be achieved this way, or am I doing this completely wrong?

 

 

-RautSa

0 Kudos
Message 1 of 3
(3,302 Views)

RauTa,

 

first check the data type of your SQL statement. I am not sure if you get a numeric here...

Second: Why would you ever want to know this?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 3
(3,300 Views)
Solution
Accepted by topic author RautSa

Thank you for your reply, Norbert. I have a database which gains new values randomly, and sometimes I need the exact number of rows in that array.

 

I managed to accomplish my goal by using SQL Statement: "SELECT COUNT(*) as Rowcount FROM TEST_TABLE", followed by a data operation GET, which saves that Rowcount to a local variable.

 

 

-RautSa

0 Kudos
Message 3 of 3
(3,267 Views)