From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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 insert table without inserting primary key

Dear Folks,

I have several LabVIEW program running at different locations writing (INSERT) to the same table of the same database.  I've set the Primary Key of the table auto-increment integer.

The problem is: I want to leave the primary key increment by itself while fill in other fields of the same record using DB TOOLS INSERT DATA, but I HAVE TO bundle an integer into the cluster (of the same size / data type of each field of a record) that corresponds to that integer primary key. Otherwise I get an error.

If I do that, then there is another problem: since I have several programs writing to the same table asychronously, I can't really keep track of the most current primary key number. Of course I can run a query, but while the query result is being returned to one LabVIEW program, another LabVIEW program might have already added a new record (therefore the primary key number changed).

Please show me a way to insert table without having the primary key bundled in.

Thanks a lot!
Toutiao
0 Kudos
Message 1 of 8
(6,873 Views)
Use the columns input to specify which columns you're inputting data into. That way, if you change the order of your columns or add other columns, your code won't break. Now you can simply not include the ID column in the cluster and it will fill automatically.

___________________
Try to take over the world!
0 Kudos
Message 2 of 8
(6,864 Views)

What is exactly is a colume input?

Thanks!

Toutiao

0 Kudos
Message 3 of 8
(6,847 Views)
BTW, I'm writing to SQL Server 2000, not Citadel by NI.
0 Kudos
Message 4 of 8
(6,847 Views)
The Insert Data VI has an input for specifying which columns you want to insert into. It's a 1D array of strings.

___________________
Try to take over the world!
0 Kudos
Message 5 of 8
(6,842 Views)
How can I specify it, using the name of each data field I defined in SQL?
 
I can't find the help file for the DB Tools ...
0 Kudos
Message 6 of 8
(6,841 Views)

I don't know how you installed the toolkit, but you should help for the function by right clicking and selecting Help. If you don't, you should reinstall the toolkit.

As for you questions - yes, columns is simply another word for fields and is a common term in databases. If you don't know much about databases, I suggest you search for some tutorials online before continuing.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
0 Kudos
Message 7 of 8
(6,837 Views)

Tst,

Many thank! I'll make sure to do the home works 🙂

Toutiao

0 Kudos
Message 8 of 8
(6,834 Views)