agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedTry catch error, return data
3+ messages / 3 participants
[nested] [flat]
* Try catch error, return data
@ 2022-02-16 02:13 Shaozhong SHI <shishaozhong@gmail.com>
2022-02-16 03:08 ` Re: Try catch error, return data Skylar Thompson <skylar2@uw.edu>
2022-02-16 10:01 ` Re: Try catch error, return data Karsten Hilbert <Karsten.Hilbert@gmx.net>
0 siblings, 2 replies; 3+ messages in thread
From: Shaozhong SHI @ 2022-02-16 02:13 UTC (permalink / raw)
To: pgsql-sql <pgsql-sql@lists.postgresql.org>
In Python, one can use try statement to catch error, error can be stored as
data.
Can plpgsql catch and return error as data or a data table?
Regards, David
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Try catch error, return data
2022-02-16 02:13 Try catch error, return data Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-02-16 03:08 ` Skylar Thompson <skylar2@uw.edu>
1 sibling, 0 replies; 3+ messages in thread
From: Skylar Thompson @ 2022-02-16 03:08 UTC (permalink / raw)
To: pgsql-sql@lists.postgresql.org
I think you're looking for EXCEPTION:
https://www.postgresql.org/docs/14/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
At the point you've trapped the error, you can then return something based
on the error. You can find a list of exception codes in one of the
appendices:
https://www.postgresql.org/docs/14/errcodes-appendix.html
On Wed, Feb 16, 2022 at 02:13:05AM +0000, Shaozhong SHI wrote:
> In Python, one can use try statement to catch error, error can be stored as
> data.
>
> Can plpgsql catch and return error as data or a data table?
>
> Regards, David
--
-- Skylar Thompson (skylar2@u.washington.edu)
-- Genome Sciences Department (UW Medicine), System Administrator
-- Foege Building S046, (206)-685-7354
-- Pronouns: He/Him/His
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Try catch error, return data
2022-02-16 02:13 Try catch error, return data Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-02-16 10:01 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
1 sibling, 0 replies; 3+ messages in thread
From: Karsten Hilbert @ 2022-02-16 10:01 UTC (permalink / raw)
To: pgsql-sql@lists.postgresql.org
Am Wed, Feb 16, 2022 at 02:13:05AM +0000 schrieb Shaozhong SHI:
> In Python, one can use try statement to catch error, error can be stored as
> data.
>
> Can plpgsql catch and return error as data or a data table?
Yes, as The Fine Manual to be Read says:
https://www.postgresql.org/docs/devel/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
https://www.postgresql.org/docs/devel/plpgsql-errors-and-messages.html#PLPGSQL-STATEMENTS-RAISE
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-02-16 10:01 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 02:13 Try catch error, return data Shaozhong SHI <shishaozhong@gmail.com>
2022-02-16 03:08 ` Skylar Thompson <skylar2@uw.edu>
2022-02-16 10:01 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox