title: Error writing trigger script on PostgreSQL
body: <p>I have a SQL script for triggers. It was automatically generated by a great software for database modelling called "Win'Design".</p>
  
  <p>So, after I created the database with all the tables (0 data) I wanted to copy/paste the script on the pgAdmin query editor.</p>
  
  <p>Here's an extract:</p>
  
  <pre><code>-- Trigger de modification ----------------------------------------------
  CREATE TRIGGER TU_SOURCE_OPEN_DATA
  AFTER UPDATE ON SOURCE_OPEN_DATA FOR EACH ROW
  EXECUTE PROCEDURE 
       -- Interdire la modification de la clé étrangère référençant la table 
       -- SOURCE_PARAMETRE.
  
       if
            :OLD.ID_SOURCE_PARAMETRE &lt;&gt; :NEW.ID_SOURCE_PARAMETRE
       then
                 raise_application_error(
                 -20008,
                 'Modification de la clé étrangère référençant "SOURCE_PARAMETRE" interdite.');
       end if;
  
  /
  
  DROP TRIGGER TI_SOURCE_OPEN_DATA;
  
  -- Trigger d'insertion ----------------------------------------------
  CREATE TRIGGER TI_SOURCE_OPEN_DATA
  AFTER INSERT ON SOURCE_OPEN_DATA FOR EACH ROW
  EXECUTE PROCEDURE 
       -- Sauf valeur nulle autorisée, interdire la création d'une occurrence de SOURCE_OPEN_DATA 
       -- s'il n'existe pas d'occurrence correspondante dans la table SOURCE_PARAMETRE.
  
       select count(*) into numrows
       from SOURCE_PARAMETRE
       where
            :NEW.ID_SOURCE_PARAMETRE = SOURCE_PARAMETRE.ID_SOURCE_PARAMETRE;
       if 
            (
            numrows = 0 
            )
       then
            raise_application_error(
                 -20002,
                 'Impossible d''ajouter "SOURCE_OPEN_DATA" car "SOURCE_PARAMETRE" n''existe pas.');
       end if;
  
  /
  
  
  
  -- ------------------------------------------------------------------------------- 
  --   Table : SECTEUR
  -- ------------------------------------------------------------------------------- 
  
  DROP TRIGGER TD_SECTEUR;
  
  -- Trigger de suppression ----------------------------------------------
  CREATE TRIGGER TD_SECTEUR
  AFTER DELETE ON SECTEUR FOR EACH ROW
  EXECUTE PROCEDURE 
       -- Supprimer les occurrences correspondantes de la table INTERESSE.
  
       delete from INTERESSE
       where
            INTERESSE.ID_SECTEUR = :OLD.ID_SECTEUR;
  
  /
  </code></pre>
  
  <p>and here's the message error :</p>
  
  <pre><code>ERROR:  syntax error at or near ":"
  LINE 9:           :OLD.ID_SOURCE_PARAMETRE &lt;&gt; :NEW.ID_SOURCE_PARAMET...
                    ^
  ********** Error **********
  
  ERROR: syntax error at or near ":"
  SQL state: 42601
  Character: 304
  </code></pre>
  
  <p>i tried deleting until "Trigger d'insertion" and still got an error</p>
  
  <pre><code>ERROR:  syntax error at or near "select"
  LINE 9:      select count(*) into numrows
               ^
  ********** Error **********
  
  ERROR: syntax error at or near "select"
  SQL state: 42601
  Character: 369
  </code></pre>
  
  <p>1st time using triggers... please help</p>
  
  <p>EDIT:
  As @Laurenz Albe and @pozs correctly pointed out, it is indeed oracle syntax. This is odd, as i specified during extraction PostgreSQL. So i tried with another Postgre9.1 and it generated this script:</p>
  
  <p>-- </p>
  
  <pre><code>------------------------------------------------------------------------------- 
  --   Table : SOURCE_OPEN_DATA
  -- ------------------------------------------------------------------------------- 
  
  DROP TRIGGER TU_SOURCE_OPEN_DATA;
  
  -- TRIGGER DE MODIFICATION --------------------------------
  
  CREATE TRIGGER TU_SOURCE_OPEN_DATA
  AFTER UPDATE ON SOURCE_OPEN_DATA
  REFERENCING OLDROW, NEWROW 
  FOR EACH ROW
  
  IMPORT
  import java.sql.* ;
  BEGIN
       -- Interdire la modification de la clé étrangère référençant la table 
       -- SOURCE_PARAMETRE.
  
       if
            OLDROW.getValue(10, CHAR);.ID_SOURCE_PARAMETRE &lt;&gt; NEWROW.getValue(10, CHAR);.ID_SOURCE_PARAMETRE
       then
                 raise_application_error(
                 -20008,
                 'Modification de la clé étrangère référençant "SOURCE_PARAMETRE" interdite.');
       end if;
  
  END;
  
  DROP TRIGGER TI_SOURCE_OPEN_DATA;
  
  -- TRIGGER D'INSERTION --------------------------------------
  
  CREATE TRIGGER TI_SOURCE_OPEN_DATA
  AFTER INSERT ON SOURCE_OPEN_DATA 
  REFERENCING OLDROW, NEWROW 
  FOR EACH ROW
  
  IMPORT
  import java.sql.* ;
  BEGIN
  
  END;
  </code></pre>
  
  <p>Again, this is just an extract. Now I get </p>
  
  <pre><code>ERROR:  syntax error at or near ";"
  LINE 11: DROP TRIGGER TU_SOURCE_OPEN_DATA;
                                           ^
  ********** Error **********
  
  ERROR: syntax error at or near ";"
  </code></pre>