This discussion is archived
2 Replies Latest reply: Mar 28, 2013 3:32 AM by David Last RSS

SDDM Beta 3.3 trigger code generation

ScottK Newbie
Currently Being Moderated
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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points