title: Creating a trigger function in PostgreSQL
body: <p>I'm creating a trigger function that must populate a field called "numero_cip". This field must be fill just one time after a "INSERT ROW", because this field is a join from: "BR" + ID FIELD + SUFIXO FIELD. </p>
  
  <p>So, i'm trying to create this trigger function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION numeradora_cip() 
  RETURNS trigger AS $$
  DECLARE 
   sufixo varchar(2);
   numero_cip varchar(60);
  BEGIN 
      sufixo := select p.sufixo from produto p where p.id = NEW.id_produto;
      NEW.numero_cip = select 'BR' || lpad(NEW.id, 11, '0') || sufixo;
      RETURN NEW;
  END;
  $$ LANGUAGE 'plpgsql';
  </code></pre>
  
  <p>But i got the error:</p>
  
  <pre><code>ERROR:  syntax error at or near "select"
  LINE 7:     sufixo := select p.sufixo from produto p where p.id = NE...
  </code></pre>
  
  <p>PS: This is my first time creating a trigger function.</p>