Search Postgresql Archives

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

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

 



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

[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