Problem with import DataTable - to DB SQL

Hello
I opened a new post, because I only partially solved my problem, with last…

I have a problem with importing a table collected from a scraping, to SQL.
This table exists on SQL, and must be overwritten in its, entirety.

With scraping, I collect the DT1 table.
I assign a variable to take the data from each column.

image

I connect to the SQL Server (ok, it works)
but when i run my query, only the last row of table DT1 is updated.

image

what am I doing wrong?
thanks.
Aaron

It appears as though you are iterating through the table in the first picture and overwriting the data in the string variable “PONumber”. In this case the string PONumber would only contain the last number inside of the table, which is why nothing else is updating.

Do you have an idea how to solve?
I have been stuck on this step since yesterday unfortunately.

I’m not the best at SQL syntax so I’m sure there is a better solution than the one I am proposing that joins the table all at once. However for it to work in the way you have coded now, the UPDATE DT1 activity needs to be inside of that for each row loop. If you place it inside then it will update each row for the PONumber since it will be iterating through. If the tables are very large though(100, 1000 or even more rows need to update) this will cause the program to be slower than I expect you would want.

I believe, and I hope there is a different way.
Tables contain thousands of data, with the number of rows varying from time to time.

If you have a DBA at your company I would suggest reaching out to them to get the syntax for updating a table all at once since the SQL you are using now is for updating rows. If you don’t have one then maybe this link can help guide you?

I’m not sure if the above helps at all, but in either case you are going to have to find an SQL statement that can handle whole table updates.

My current flow, for testing, is this.
BlankProcess1.zip (19,9 KB)

I need to copy the “Elenco” sheet into an SQL table. ‘elenco’.

If this DB table is empty, enter the data from the table.
If the DB table is full, clear and overwrite.

Every day the bot passes, and it has to load new elements, deleting those of the previous RUN.

Can someone help me?

Use first excute with “truncate table;”

Then perform the insert:

Thanks Moenk,
OK, the existing table is deleted with Truncate …
My initial problem remains.
Probably due to an incorrect use of the command.
I entered an “execute non query” of uipath, with string:
“INSERT Into list (PONumber, POContactPerson, Offer, LastPing) VALUES (?,?,?,?)”

my problem is that it doesn’t load all the collected table, but only the last row.
I should load the whole table in full.
Can help with this?

Maybe it makes a difference “execute query” versus “execute non query”?
I didn’t understand the difference actually.

Dont prepare the insert yourself, there is an activity for that.

I saw, but got error with that too.
Maybe I’m wrong to enter the command configuration data.

I created a second table, with the name of the columns, as they are taken.

image

I entered the command, as indicated below, but I am getting an error.
image

image

Okay, I got another piece of information.
My query only updates one row, because a Where condition is missing, which perhaps is mandatory.
I added a check on “LastPing”, which contains a date field.

I collected the new table from the web.
I added the LastPing column, inserting today’s date.
(date of extraction from the web)
image

I then created a table on SQL, with identical structure.
image

Then, I wrote the query:

"UPDATE elenco SET (PONumber, LastPing) =(?,?) Where LastPing != “+now.Tostring(“dd/MM/yyyy”)+” "

But again, it points me to incorrect syntax.

image

What’s missing now? :expressionless:

Anyone know what I’m doing wrong?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.