Jump to content
Sign in to follow this  
Gael Anquetil

Insert multiple rows into database

Recommended Posts

Hello,

I am using  NI_Database_API.lvlib on Labview 2017. I am tringot insrt multiple rows into table but I have the error : 'Semicolon seperatot is missing at the end of the query.'

Plaese find below my command to insert two rows onto one table T_Column ( C_Name as String, C_Status as String).

INSERT INTO T_Column (C_Name , C_Status)
VALUES('21' , 'Not realised'),
('22' , 'Not realised');

How do I must modify the query? Is it possible to insert multiple rows using Microsoft.oledb.4.0?

Thanks for your help.

Share this post


Link to post
Share on other sites

Depends on the database. For example, oracle does not support multiple inserts in a single query like that. Instead you'd have to use:

INSERT INTO T_Column (C_Name , C_Status) VALUES('21' , 'Not realised');
INSERT INTO T_Column (C_Name , C_Status) VALUES('22' , 'Not realised');

On the one hand this sucks, but on the other hand if you're using oracle this is probably the least of your worries. :(

 

On a related note, it looks like you are manually generating sql queries. While fine for development, its generally recommended to use parameterized statements to help avoid sql injection attacks.

Share this post


Link to post
Share on other sites
On 6/25/2019 at 11:04 PM, smithd said:

On a related note, it looks like you are manually generating sql queries. While fine for development, its generally recommended to use parameterized statements to help avoid sql injection attacks.

Obligatory Bobby Tables reference

 

1_P4nj9fJjSeJ9-c0rwSZqlg.png

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites

Does anybody found a solution to execute multiple insert query??

Because now I need to insert like 250000 rows and it takes a journey to do this... I think there is a parameter I need to modify in the connector or seems like that to allow multiple queries.

Thank you for your help...it's quite urgent...

Share this post


Link to post
Share on other sites

I've done it using a parameterized query:

image.png.3c20c5189376c79d4da426145999b2b8.png

Share this post


Link to post
Share on other sites
9 hours ago, jcarmody said:

I've done it using a parameterized query

Wrapping the queries in a transaction ("BEGIN TRANSACTION" + "END TRANSACTION") could speed things up a lot for 250000 rows

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.