Search Postgresql Archives

Re: RAISE with C?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

2010/12/20 Elliot Chance <elliotchance@xxxxxxxxx>:
> Hi,
>
> Is it possible to do the equivalent of RAISE EXCEPTION inside a C-function? Like this:
>
>

sure, there are functions elog and ereport

Regards

Pavel Stehule

> 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
> --
> Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux