Jump to content

Insert multiple rows into database


Recommended Posts

Posted

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.

Posted

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.

Posted
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
  • 4 months later...
Posted

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...

Posted
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

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

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