RAISE with C?

Поиск
Список
Период
Сортировка
От Elliot Chance
Тема RAISE with C?
Дата
Msg-id D0427C33-CE68-4457-9F5A-368A6A386A00@gmail.com
обсуждение исходный текст
Ответы Re: RAISE with C?  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
Hi,

Is it possible to do the equivalent of RAISE EXCEPTION inside a C-function? Like this:


PG_FUNCTION_INFO_V1(check_something);
Datum check_something(PG_FUNCTION_ARGS)
{
    // RAISE EXCEPTION 'bla bla'
}

CREATE OR REPLACE FUNCTION do_check() RETURNS text AS $$
BEGIN
    PERFORM check_something();
    RETURN 'All good';
EXCEPTION
    WHEN RAISE EXCEPTION THEN
        RETURN 'Something bad';
END;
$$ LANGUAGE plpgsql IMMUTABLE;


That code may not work but you get the idea, I want to throw an exception from a C function that can be caught in
PL/pgSQL.Also is it further possible to catch the message that RAISE EXCEPTION sends? Like 'Something bad: bla bla' 

Thanks,
Elliot

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

Предыдущее
От: tbazadaykin
Дата:
Сообщение: Re: Need More Case Studies on PostGIS
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: RAISE with C?