Re: Implementation of SQLSTATE and SQLERRM variables

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Implementation of SQLSTATE and SQLERRM variables
Дата
Msg-id Pine.LNX.4.44.0505260858410.29321-100000@kix.fsv.cvut.cz
обсуждение исходный текст
Ответ на Re: Implementation of SQLSTATE and SQLERRM variables  (Neil Conway <neilc@samurai.com>)
Ответы Re: Implementation of SQLSTATE and SQLERRM variables
Список pgsql-patches
> I think the docs need more than just "these variables are set when an
> exception is raised".
>
> The patch current resets SQLSTATE and SQLERRM whenever a new block is
> entered. So:
>
> create function trap_exceptions() returns void as $_$
> begin
>     begin
>       raise exception 'first exception';
>     exception when others then
>       raise notice '% %', SQLSTATE, SQLERRM;
>       begin
>         raise notice '% %', SQLSTATE, SQLERRM;
>       end;
>     end;
>     return;
> end; $_$ language plpgsql;
>
> The second RAISE will report "successful completion". Is this the
> behavior we want?

True, its foggy behave. Only if block contains exception than variables
SQLSTATE and SQLERRM are created.

>
> Is SQLERRM the best name for that variable? It seems a little obscure to me.
>

This name use Oracle in PL/SQL. ESQL Oracle and DB2 too. I think so is
better use well knowed names for it than creating own. There is one
argument for it. PL/pgSQL is language very similar Oracle PL/SQL. PL/SQL
know SQLERRM, SQLCODE and SQLSTATE. An people which know PL/SQL will like
use this names in Pg.

Pavel Stehule


> -Neil
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq
>


В списке pgsql-patches по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Remove second argument from textToQualifiedNameList
Следующее
От: ITAGAKI Takahiro
Дата:
Сообщение: O_DIRECT for WAL writes