Forum: Managing VoltDB

Post: Inserting multiple rows in to voltdb

Inserting multiple rows in to voltdb
Harsha Raj
Feb 16, 2013
Hi,

I have a query taken from mysql
i.e insert into state_details values (19044,183),(19046,183),(19047,183),(19048,183),(19049,183),(19069,183),(19070,183),(19071,183);

the above query contain multiple values to be inserted into the table state_details, when ran from the voltdb command prompt only the one row will be inserted.

sqlcmd
SQL Command :: localhost:21212
1> INSERT INTO state_details VALUES (19044,183),(19046,183),(19047,183);


(1 row(s) affected)
2> select * from state_details;
CAMPAIGNID STATEID
----------- --------
19044 183



(1 row(s) affected)

Please let me know how we can insert multiple rows at a time.

Thanks in Advance,
Harsha Raj D
rbetts
Feb 16, 2013
The most direct way to transactionally insert multiple rows is to pass an array of data to the stored procedure and then iterate that array and do inserts one-by-one.

If you don't need the inserts to occur in the same transaction, you can simply do multiple inserts - there's very rarely a reason to batch for performance's sake.

I looked around but can not find a simple example of using arrays; let me know if that's your requirement and we'll provide a code sample.

Thanks,
Ryan.
rbetts
Feb 16, 2013
The most direct way to transactionally insert multiple rows is to pass an array of data to the stored procedure and then iterate that array and do inserts one-by-one.

If you don't need the inserts to occur in the same transaction, you can simply do multiple inserts - there's very rarely a reason to batch for performance's sake.

I looked around but can not find a simple example of using arrays; let me know if that's your requirement and we'll provide a code sample.

Thanks,
Ryan.