From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Database Progressive Logging

I'm trying to use LabView's Database connectivity toolkit to store temperature and pressure data similar to the method in the example library (below)

 

Create, then LogCreate, then Log

 

What would be the best way to change this vi to log data progressively during a test as opposed to after the system finishes generating data?

0 Kudos
Message 1 of 6
(3,009 Views)

How often is "progressively"?

I generally avoid doing that.

 

0 Kudos
Message 2 of 6
(2,984 Views)

Ideally, about one data point every 0.25 sec

However, I'd be ok with bundling the data elsewhere and doing multiple data points at a time once per hour

0 Kudos
Message 3 of 6
(2,980 Views)

You don't want to be opening/closing a database every 250 msec.

0 Kudos
Message 4 of 6
(2,974 Views)

@njacacia wrote:

You don't want to be opening/closing a database every 250 msec.


Ok, What is the best way to go from a data stream (Which will run for days+) to a database?

0 Kudos
Message 5 of 6
(2,965 Views)

Assuming SQL (I'm not experienced enough to know if this applies to other Database servers).  Use basic Insert statements (use string commands).

 

In this manner, you only need "DB Open Connection.vi", "DB Execute Query.vi", "DB free object.vi", and "db close connection.vi"

We will build an insert statement and wire it to the SQL query of the DB Execute Query.vi

 

Assuming a table with 2 names ("column A", "column B") named Test_Table.

"Insert Into Test_Table (column A, column B)
Values (1,2),(3,4)(5,6)"
Will insert the following.
Column A  ColumnB
1                  2
3                  4
5                  6


In this manner, a single connection and insert statement can insert multiple records.  Simply store your data for a predetermined # of records (shift register for example), then create and execute the insert statement.  Each row of data is contained within the parenthesis.  The comma delimited list can be extended as far as you want (be wary of timeouts however).

 

Adjust column names and the number of columns as you require.  I hope i attached the snippet properly.

 

 

0 Kudos
Message 6 of 6
(2,958 Views)