Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Migration Workbench -- Access migration code contains an infinite loop

JustinCaveOct 20 2009 — edited Oct 23 2009
Based on a discussion that started over in the Database - General forum, it appears that the trigger code generated by the SQL Developer Migration Workbench may contain an infinite loop.

976432

The trigger that is generated
create or replace TRIGGER t_xxx_fld01_TRG BEFORE INSERT OR UPDATE ON t_xxx
FOR EACH ROW
DECLARE
v_newVal NUMBER(12) := 0;
v_incval NUMBER(12) := 0;
BEGIN
  IF INSERTING AND :new.fld01 IS NULL THEN
    SELECT  t_xxx_fld01_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
    -- If this is the first time this table have been inserted into (sequence == 1)
    IF v_newVal = 1 THEN
      --get the max indentity value from the table
      SELECT max(fld01) INTO v_newVal FROM t_xxx;
      v_newVal := v_newVal + 1;
      --set the sequence to that value
      LOOP
           EXIT WHEN v_incval>=v_newVal;
           SELECT t_xxx_fld01_SEQ.nextval INTO v_incval FROM dual;
      END LOOP;
    END IF;
    -- save this to emulate @@identity
   msaccess_utilities.identity := v_newVal;
   -- assign the value from the sequence to emulate the identity column
   :new.fld01 := v_newVal;
  END IF;
END;
stores the MAX(fld01) in v_newVal if the sequence has a value of 1. If the table is empty, however, the MAX(fld01) will be NULL. So the loop condition becomes
EXIT WHEN v_incval >= NULL
which will never be satisfied.

Pierre generated the trigger above using SQL Developer 1.5.5, Access 2003, and Oracle 10.2.0.4

Justin

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 20 2009
Added on Oct 20 2009
4 comments
778 views