Re: How do Exception, do nothing and carry on - Mailing list pgsql-sql

From David G. Johnston
Subject Re: How do Exception, do nothing and carry on
Date
Msg-id CAKFQuwaaStSXsa0ZbBAxUujY02iUgCTJF=X3m0kCbPq=Lk+gLw@mail.gmail.com
Whole thread Raw
In response to How do Exception, do nothing and carry on  (Shaozhong SHI <shishaozhong@gmail.com>)
List pgsql-sql


On Thursday, July 6, 2023, Shaozhong SHI <shishaozhong@gmail.com> wrote:
The function in the following block code may fail.

How to make it to carry on by ignoring exception?

Something like Python's try catch.

for i in (select distinct id from id_table) 
  loop
         raise notice '%', i;
           insert into my_table(id, last, arr, count) SELECT i, * from my_function(i) f(last int, arr int[], count int);
           commit;

  end loop;

Create a new function that traps [1] the failure and throws it away, then call that function instead.


David J.

pgsql-sql by date:

Previous
From: Shaozhong SHI
Date:
Subject: How do Exception, do nothing and carry on
Next
From: Shaozhong SHI
Date:
Subject: How to remove duplicates in an array and maintain the order?