How to raise error from PostgreSql SQL statement if some condition is met

Поиск
Список
Период
Сортировка
От Andrus
Тема How to raise error from PostgreSql SQL statement if some condition is met
Дата
Msg-id 9E0A5B8931B849A4844AE348C4A0CC34@dell2
обсуждение исходный текст
Ответы Re: How to raise error from PostgreSql SQL statement if some condition is met  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: How to raise error from PostgreSql SQL statement if some condition is met  (Craig Ringer <ringerc@ringerc.id.au>)
Re: How to raise error from PostgreSql SQL statement if some condition is met  (Craig Ringer <ringerc@ringerc.id.au>)
Список pgsql-general
I’m looking for a way to raise error from sql select if some condition is met.
Tried code below to got error shown in comment.
How to fix ?
 
Andrus
 
    CREATE OR REPLACE FUNCTION "exec"(text)
      RETURNS text AS
    $BODY$
        BEGIN
          EXECUTE $1;
          RETURN $1;
        END;
    $BODY$
      LANGUAGE plpgsql VOLATILE;
     
    -- ERROR:  syntax error at or near "raise"
    -- LINE 1: raise 'test'
   
    select exec('raise ''test'' ') where true -- in real application true is replaced by some condition

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

Предыдущее
От: Dan Halbert
Дата:
Сообщение: Re: select distinct in a subquery bug/problem
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: How to raise error from PostgreSql SQL statement if some condition is met