LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Statements with SQL Toolkit Library

What is the simplest way to do the following :
my program uses 2 tables. In the first one, I add data using automatic SQL (maps). The first column of this table is a primary key with auto-increment. After insertion of the record, I want to know the key value of the newly inserted record, in order to add related data to the second table (a set of records which are in relation with the record of the first table, i.e. one to many relationship through the key value)
0 Kudos
Message 1 of 2
(3,001 Views)
Hello krist11.

I'm a spanish Cvi programmer , I'm sorry but My English is very bad.

It's very easy:
1 First you add your data.
2 You can do a "Select" to the first table . In this select , you may find the MAX value of Key value of the first table. This select make a one Register with the Primary Key value of the Newly inserted record. This de value for the second table.

The select for do this is :
SELECT Max(First_Table.PrimaryKey)
FROM First_Table;

Execute this sql command and after create a function to see the record of the request of the select , is very easy , if have problems , tell me . Send a mail to f.bermejo.garapen@adegi.es , I will send a code to do it in Cvi.

Thanks
Tximis
0 Kudos
Message 2 of 2
(3,001 Views)