How do Exception, do nothing and carry on

From: Shaozhong SHI <shishaozhong(at)gmail(dot)com>
To: pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: How do Exception, do nothing and carry on
Date: 2023-07-06 21:47:12
Message-ID: CA+i5Jwa9E1RyApZYViBgG9yyCRT5V4WKRAeWDXuVe_1qf4uCsA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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;

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2023-07-06 21:54:46 Re: How do Exception, do nothing and carry on
Previous Message Tom Lane 2023-07-06 16:12:01 Re: How to select the last value/row?