title: How to declare a function in a trigger - Oracle
body: <p>I dont know how to do this trigger with an internal function in Oracle </p>
  
  <pre><code>CREATE OR REPLACE TRIGGER promo 
  AFTER INSERT ON promociones 
  FOR EACH ROW 
  DECLARE nomb VARCHAR2(20); times NUMBER; cont NUMBER;
  FUNCTION veces (promo VARCHAR2(20)) 
  RETURN NUMBER as cont 
  BEGIN 
  SELECT count(*) INTO cont FROM promociones WHERE id2=promo;
  RETURN cont;
  END veces; 
  BEGIN 
      times:= veces(:new.id2); 
      SELECT nombre into nomb FROM promociones WHERE id=:new.id2;
      DBMS_OUTPUT.PUT_LINE (nomb || times);
  END;
  /
  </code></pre>
  
  <p>Then says me: 'Encountered the simbol "(" when expecting one of the following: := . ) , @ % default character. The symbol ":=" was substitutd for "(" to continue.
  '
  'Encountered the symbol "BEGIN" when expecting one of the following: constant exception (an identifier) (a double-quoted delimited-identifier) table long double ref char timestamp interval date binary national character nchar.'
  'Encountered the symbol "end-of-file" when expecting on of the following: begin function pragme procedure'</p>
  
  <p>How is the real syntax of this trigger? help me please.</p>