หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
This article describes the reason why SQL Server Migration Assistant (SSMA) for Oracle adds ROWID column to the table, if there are triggers.
Background
In Oracle, you can create a trigger that runs FOR EACH ROW, rather than for the entire set of rows that is changing. In SQL Server, triggers always execute for the entire set of modified rows. If row-level Oracle trigger accesses both - :old and :new special variables, then SSMA needs a way to match rows from both row sets in order to identify what the value was for a given row before and after the update. To emulate such for each row functionality, SSMA adds special ROWID column to uniquely identify each modified row and uses it to establish a relationship between inserted and deleted row sets.
Example
In the following example, an Oracle trigger executes for each row updated in TRIG_TEST table:
CREATE OR REPLACE TRIGGER TSCHM.TRIG_TEST_AU
AFTER UPDATE OF DATA ON TSCHM.TRIG_TEST
FOR EACH ROW
BEGIN
IF (:new.DATA = 'ABC') THEN
INSERT INTO TSCHM.TRIG_TEST(DATA) VALUES ('-' || :old.DATA);
END IF;
END;
When you try to convert this trigger in SSMA, the following T-SQL is produced within the SQL Server trigger:
Run a cursor over
insertedrow set, selectingROWIDandDATAcolumns into@new$0and@new$DATAvariables:DECLARE ForEachInsertedRowTriggerCursor CURSOR LOCAL FORWARD_ONLY READ_ONLY FOR SELECT ROWID, DATA FROM inserted OPEN ForEachInsertedRowTriggerCursor FETCH ForEachInsertedRowTriggerCursor INTO @new$0, @new$DATAIn a loop, select matching row from
deletedrow set into@old$0and@old$DATAvariables, based on the insertedROWID(stored in@new$0variable):SELECT @old$0 = ROWID, @old$DATA = DATA FROM deleted WHERE ROWID = @new$0Perform trigger actions using
@old$DATA/@new$DATAvariables:IF (@new$DATA = 'ABC') INSERT SSMAADMIN.TRIG_TEST(DATA) VALUES (('-' + ISNULL(@old$DATA, '')))
Additional information
This behavior is controlled by the Generate ROWID column project setting, which can be found under Tools > Project Settings > General > Conversion > ROWID generation. If the setting is set to No, but during trigger conversion SSMA identifies that it requires a ROWID column, then O2SS0239 conversion error is generated.
Related conversion messages
- O2SS0239: ROWID column not accessible (Error)
- O2SS0267: ROWID column
- O2SS0404: ROWID column can not be converted