How To Insert Multiple Statements in One verticacommand

Moderator: NorbertKrupa

Post Reply
ajit_nayak
Newbie
Newbie
Posts: 15
Joined: Tue May 14, 2013 1:25 pm

How To Insert Multiple Statements in One verticacommand

Post by ajit_nayak » Tue May 14, 2013 1:40 pm

Hi,

I have 3 insert statements like
INSERT INTO table(col1,col2,col3)values (value1,value2,value3);
INSERT INTO table(col1,col2,col3)values (value1,value2,value3);
INSERT INTO table(col1,col2,col3)values (value1,value2,value3);

My query is to insert it in a single command object i.e.
I created
VerticaCommand command = new VerticaCommand (Parameters);
----
----
command.ExecuteNonQuery(); // I need this statement will execute once for above 3 statements.

But Vertica doesn't taking these how can I do this,If anybody knows,plz guide.


Thanks,
Ajit Kumar Nayak
ajit.nayak@vichara.com

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: How To Insert Multiple Statements in One verticacommand

Post by JimKnicely » Tue May 14, 2013 1:56 pm

Hi,

Welcome to the forums!

Check out the following post which may help you out:

http://www.vertica-forums.com/viewtopic.php?f=63&t=998

I'm thinking you gotta do something like this:

Code: Select all

INSERT INTO table (col1, col2, col3)
  SELECT value1, value2, value3
   UNION
  SELECT value1_2, value2_2, value3_2
   UNION
  SELECT value1_3, value2_3, value3_3;
Hopefully Vertical will give a multi-record insert command in a future release!
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

ajit_nayak
Newbie
Newbie
Posts: 15
Joined: Tue May 14, 2013 1:25 pm

Re: How To Insert Multiple Statements in One verticacommand

Post by ajit_nayak » Wed May 15, 2013 6:26 am

Thanks Jim Knicely

It helps me lot.

Thanks
Ajit

Post Reply

Return to “Vertica Database Development”