public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: Shaozhong SHI <[email protected]>
Cc: pgsql-sql <[email protected]>
Subject: Re: How do Exception, do nothing and carry on
Date: Thu, 6 Jul 2023 14:54:46 -0700
Message-ID: <CAKFQuwaaStSXsa0ZbBAxUujY02iUgCTJF=X3m0kCbPq=Lk+gLw@mail.gmail.com> (raw)
In-Reply-To: <CA+i5Jwa9E1RyApZYViBgG9yyCRT5V4WKRAeWDXuVe_1qf4uCsA@mail.gmail.com>
References: <CA+i5Jwa9E1RyApZYViBgG9yyCRT5V4WKRAeWDXuVe_1qf4uCsA@mail.gmail.com>
On Thursday, July 6, 2023, Shaozhong SHI <[email protected]> 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.
[1]
https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
David J.
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: How do Exception, do nothing and carry on
In-Reply-To: <CAKFQuwaaStSXsa0ZbBAxUujY02iUgCTJF=X3m0kCbPq=Lk+gLw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox