I
I
Ivan2016-11-28 09:18:55
SQL Server
Ivan, 2016-11-28 09:18:55

How to fix the error through try catch and return to the beginning of the try?

There is a table in which the idnt_code field must be unique, and there is another table from which data is transferred to this table, including in the idnt_code field. But it happens that some lines come already with the value that already exists. I need to get this line in catch, perform some manipulations so that it can be recorded, recorded and continue the try. It is clear that try has already completed its work, so I will have to execute it again.
Is it even possible to work with a building that has an error in the catch?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Karetnikov, 2016-11-28
@art_karetnikov

No need. This will be an individual work with each line and it will slow down. And you need to make a selection of a bunch of rows at once, check through exists / in that they are not in the target table and immediately insert them in a bunch.
And those that are present in the target, the next step is to process and again insert the pack.
No try catch is needed at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question