How to insert more than one line via insert?

Hello friends,

I’m new here on the forum, and I know they’ll be able to help me, I’m using the Uipath.Database activity and the ‘Execute non Query’ activity to insert data directly into the bank, but I’m having trouble when the insert has more than one line me returns error. You can help me to make an insert with more than registration in the case as an example.

image


Tks Guys

Hello @oliver.junior,

Have you tried with Bulk insert method??

1 Like

Hello @oliver.junior ,
Build a datatable abcDT with the data that you need to insert into Database.
Pass abcDT datatable to the below activity that is present in Uipath.Database Package.
Capture2

2 Likes

Hello, @rohith.prabhu and how could I use or insert in bulk? would be the INSERT activity?
Could you please clarify me?

Hello, @poorna_nayak07 I tried to use this method too and I can’t enter how to play as two lines that I need in the Data Table.
How could I configure the activity to insert the two lines below?

“insert into RESCISAOMOVIM (CODIGOEMPRESA, COMPLEMENTAR, CODIGOFUNCCONTR, CODIGOEVENTO, SEQ, REFEREVENTO, VALOREVENTO, ORIGEMDADO, CODIGOPROFTIPOAULA, CODIGOOUTEMP, CODIGOCENTROCUSTO, BUSCARULTVALORCALC, CODIGOBENEF) values (712, 1, 29, 63, 1, 0, 1, 2, null, null, null, ‘0’, null);
insert Into RESCISAOMOVIM (CODIGOEMPRESA, COMPLEMENTAR, CODIGOFUNCCONTR, CODIGOEVENTO, SEQ, REFEREVENTO, VALOREVENTO, ORIGEMDADO, CODIGOPROFTIPOAULA, CODIGOOUTEMP, CODIGOCENTROCUSTO, BUSCARULTVALORCALC, CODIGOBENEF) values (712, 1, 29, 754, 1, 60, 0, 2, null, null, null, ‘0’, null);”

Thankful :slight_smile:

Hello @oliver.junior
Refer these 2 files
ToBeInserted.xlsx (8.7 KB) Sequence.xaml (4.8 KB)

2 Likes

Hello @oliver.junior,
You can insert Data into DB Table with 2 methods:

  1. Bulk Insert

    The following BULK INSERT statement imports the CSV file to the Sales table.
BULK INSERT Sales
FROM 'C:\1500000 Sales Records.csv'
WITH (FIRSTROW = 2,
    FIELDTERMINATOR = ',',
    ROWTERMINATOR='\n' );

here change firstrow, Fieldterminator, Rowterminator accourding to your need.

Method 2 : Insert Into


Read csv / directly pass DataTable to insert DB activity with in_TableName as your DB Table name.

Hope this helps !!

Regards,
Rohith

2 Likes

Thank you guys ,

I will be testing all methods and see which one best applies to my activity, thank you very much for your personal strength.
Tks guys