NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I configure the Databse Options to save an array of strings to a table?

I have a list of devices associated with a particular test and I have an array with the serial numbers of all the devices. In order to log this information to a database, I created a table with two fields: UUT_RESULT_ID, and DEVICE_SERIAL_NUMBER. Both of this make-up the Primary Key. I need to store each element in my array to a different row in the table and use the ID from the UUT_RESULT table as a foreign key in my new table.

I could write some code to log this data in the database afterwards but I need to know what was the ID generated in the UUT_RESULT table, and I would not like to assume that the last record in that UUT_RESULTS table is what I'm looking for.

Any ideas?
0 Kudos
Message 1 of 4
(3,689 Views)
Well, well, well! Looks like I'm answering my own question here! After trying many many things, I finally figured this out and I wanted to share the information in case anyone else needs it.

I needed to save multiple rows of data in a table of my database for every UUT. The configuration screen for the database options allows you to insert statements into your schema. By inserting multiple statements that save data in the same table, you insert multiple rows in that table. The problem with this solution, is that you must know how many elements or how many rows you will be saving and you should create a statement for every element in your array.

In my case the array could have any number of elements.
The solution is to modify the DatabaseOptions parameter in
the process model dynamically. There is a callback in the process model called LogToDatabse. It calls a sequence in Database.seq. To dynamically modify the DatabaseOptions insert steps before this call that insert the elements you need into Parameters.DatabaseOptions.DatabaseSchema.Statements.

This worked great for me!
Message 2 of 4
(3,689 Views)
Nice solution, seems like this might be useful for a few of my database dilemas.

I took a slightly different approach to logging the equipment list. I created a custom step type that has the relavent equipment information. I loop through the equipment list, creating step results for each item. I then added a statement in the database options that looks for that specific step type and logs the equipment. Logging the equipment list is a pretty common thing for anyone doing traceable calibrations, so it would be nice if there was some more support for this in TestStand.
0 Kudos
Message 3 of 4
(3,689 Views)
Marcela.
What you did sounds great.
I'm experiencing exactly the same problem you had. What I need is to store 600 Records in the same table every time I run a UUT. I'm trying to do what you did. I think I'm getting close, but I do have a question, how can I insert elements into Parameters.DatabaseOptions.DatabaseSchema.Statements?
I hope you can help me.

Thanks!, Erika (erika@ieee.org)
0 Kudos
Message 4 of 4
(3,688 Views)