2 Replies Latest reply: Mar 28, 2013 5:32 AM by David Last-Oracle RSS

    SDDM Beta 3.3 trigger code generation

    ScottK
      If you are generating PL/SQL trigger code in Oracle 11gR2 you can replace the following the SQL SELECT statement with a straight next value sequence number assignment. It is cleaner, easier to read and debug.


      ---- old way start

      CREATE OR REPLACE TRIGGER address_type_Address_Type_ID
      BEFORE INSERT ON Address_Type
      FOR EACH ROW
      WHEN (NEW.Address_Type_ID IS NULL)
      BEGIN
      SELECT address_type_Address_Type_ID.NEXTVAL INTO :NEW.Address_Type_ID FROM DUAL;
      END;
      /

      ---- old way end
      ---- new way start

      CREATE OR REPLACE TRIGGER address_type_Address_Type_ID
      BEFORE INSERT ON Address_Type
      FOR EACH ROW
      WHEN (NEW.Address_Type_ID IS NULL)
      BEGIN
      :NEW.Address_Type_ID := address_type_Address_Type_ID.NEXTVAL;
      END;
      /


      ---- new way end