pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedpl/pgsql and error handling
4+ messages / 3 participants
[nested] [flat]
* pl/pgsql and error handling
@ 2008-02-28 19:10 Alex Hochberger <alex@dsgi.us>
0 siblings, 1 reply; 4+ messages in thread
From: Alex Hochberger @ 2008-02-28 19:10 UTC (permalink / raw)
To: pgsql-sql
Is it possible to grab access to the actually user-friendly error
message? I have a bunch of files that come into my database, each
slightly different. The submitter fills out a form that records the
info, and sticks it into a table.
If the file is malformed (wrong number of columns in a row) from a
missing comma or something, I want to record the result to store in
the database. I assume that I should exception handle the COPY FROM
line, and store the results, but I can't for the life of me figure out
how to get the text like "invalid line on line 470352" or whatever
psql shows. Is that possible to obtain in plpgsql?
I've done extensive plpgsql programming before, but this is the first
time I need it to validate the external data in question.
Alex
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pl/pgsql and error handling
@ 2008-02-29 04:43 Tom Lane <tgl@sss.pgh.pa.us>
parent: Alex Hochberger <alex@dsgi.us>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2008-02-29 04:43 UTC (permalink / raw)
To: Alex Hochberger <alex@dsgi.us>; +Cc: pgsql-sql
Alex Hochberger <alex@dsgi.us> writes:
> Is it possible to grab access to the actually user-friendly error
> message?
Doesn't the SQLERRM variable do what you want?
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pl/pgsql and error handling
@ 2008-02-29 05:29 Alex Hochberger <alex@dsgi.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Alex Hochberger @ 2008-02-29 05:29 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
I do not know. It's sounds like the Oracle PL/SQL behavior is what I
want. Does PostgreSQL's pl/pgsql have such a feature? It's not in
the documentation anywhere. I'll check it from the office tomorrow.
Alex
On Feb 28, 2008, at 11:43 PM, Tom Lane wrote:
> Alex Hochberger <alex@dsgi.us> writes:
>> Is it possible to grab access to the actually user-friendly error
>> message?
>
> Doesn't the SQLERRM variable do what you want?
>
> regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pl/pgsql and error handling
@ 2008-02-29 07:44 Bart Degryse <Bart.Degryse@indicator.be>
parent: Alex Hochberger <alex@dsgi.us>
0 siblings, 0 replies; 4+ messages in thread
From: Bart Degryse @ 2008-02-29 07:44 UTC (permalink / raw)
To: Alex Hochberger <alex@dsgi.us>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING would be the place to look.
>>> Alex Hochberger <alex@dsgi.us> 2008-02-29 6:29 >>>
I do not know. It's sounds like the Oracle PL/SQL behavior is what I
want. Does PostgreSQL's pl/pgsql have such a feature? It's not in
the documentation anywhere. I'll check it from the office tomorrow.
Alex
On Feb 28, 2008, at 11:43 PM, Tom Lane wrote:
> Alex Hochberger <alex@dsgi.us> writes:
>> Is it possible to grab access to the actually user-friendly error
>> message?
>
> Doesn't the SQLERRM variable do what you want?
>
> regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org ( http://archives.postgresql.org/ )
---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at
http://www.postgresql.org/about/donate
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2008-02-29 07:44 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-02-28 19:10 pl/pgsql and error handling Alex Hochberger <alex@dsgi.us>
2008-02-29 04:43 ` Tom Lane <tgl@sss.pgh.pa.us>
2008-02-29 05:29 ` Alex Hochberger <alex@dsgi.us>
2008-02-29 07:44 ` Bart Degryse <Bart.Degryse@indicator.be>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox