title: Raising error in postgreSQL
body: <pre><code>CREATE OR REPLACE FUNCTION msgfailerror() RETURNS trigger AS 
  ' BEGIN 
      IF NEW.noces&lt; new.first_column THEN 
          RAISE EXCEPTION 'cannot have a negative salary'; 
      END IF; 
     return new; 
  END' LANGUAGE plpgsql
  </code></pre>
  
  <p>Trigger</p>
  
  <pre><code>create trigger msgfail before insert on first for each row 
  execute procedure msgfailerror()
  </code></pre>
  
  <p>Giving error:</p>
  
  <blockquote>
    <p>syntax error at or near "cannot" LINE 5:                     RAISE
    EXCEPTION 'cannot have a negative ...</p>
  </blockquote>
  
  <p>I have almost one validation for each field of row. I want trigger to check all validations while insertion is being done and, raise error log afterwards once for all. Should I use raise exception on raise notice ?</p>
  
  <p>For example:</p>
  
  <pre><code>Insert into first (first_column, noces,dob) values ('4545','75','545') 
  </code></pre>
  
  <p>I am checking <code>noces</code> is less than <code>first_column</code>, for the same row i want to check if dob > 80 and if first_column is integer and raise error for all validations. Thanks in advance</p>