sql_LV Documentation


The sql_LV library has 3 main functions;
  1. Gives the LabView user the ability to INSERT data into his DB
  2. Retrieve or SELECT data from his DB
  3. Process or apply arbitrary SQL to his DB
Of course, the library includes ancillary functions for opening and closing DB sockets and for error processing.

All of the following instructions for using sql_LV are based on test.vi.

Insert Data

The data cluster can be built up with constant/bundle-by-name, where the element names match the DB column names and the element types match the DB column types.  Date/times and datetimes are handled as LV Str types.
insert usage

SELECT Data

The user needs to define a cluster constant with element names that correspond to the retrieved field and must chose the correct type.  Once the data has been retrieved, the user must convert the output Variant type to cluster data using the LabView function for that.  If only one row of data is selected, the output array will be 1 element and may be indexed before, or after, type conversion.  Of course, field names may be changed for readability if desired as in the example.
SELECT and rename

JOIN Tables

Technical data, the likes of which LabView is most used with, is often stored as a header record with swept data results stored to another table.  Of course, SQL JOINs are exactly the method used to retrieve such data and sql_select.vi doesn't distinguish between tables or joined tables.  An example JOIN and element renaming are shown here.
Table Joins

Generic SQL

Generic SQL commands may be processed with sql_cmd.vi.  The intent is to use this VI to create tables and procedures, specifically for your flavor of SQL.

Generic SQL commands with output may be processed with sql_cmd_resp.vi.  This works well when calling procedures or special RDBMS functions.  Also, when the user calls aggregate functions (such as "average()" or "sum()") on large tables with indexing, huge efficiencies can be obtained by using sql_cmd_resp.vi and using the DB server to process the query instead of bringing all the data into LabView (through a networking layer) and processing.
Generic SQL processing