How to transfer data from one table to another with exception handling in Postgresql?
0
votes
0
answers
387
views
So, I have two tables, one where I import data from an excel file all in string format without considering any sorts of constraints or data type validation. And then the data is transferred to the actual table where those data are stored in proper structure.
I have something like
insert into "actualtable" (cols)
select cols
from "dumptable"
where condition;
Now I want to handle exception, for example, I want to determine the type of error occurred during transfer and update the dumptable
with proper status message for each row, which will be shown to the client so that they know what specific row of their excel file has what specific problem.
How do I do that? I wanted to do something like
exception when then
update "dumptable" set status = where "id" =
But I am unable to identify the exceptionRowId
thing.
Is there a way to do that?
Since the excel files are really huge (millions of rows), I thought something like this would be preferable over looping over a cursor. Correct me if I am wrong, and suggest the best approach.
Asked by Bibek Shah
(111 rep)
Jul 2, 2021, 04:48 AM