Skip to content

Commit ad5f287

Browse files
committed
Add SSMA articles for ROWID conversion messages
1 parent d651872 commit ad5f287

6 files changed

Lines changed: 324 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: "DB22SS0028: ROWID column generated (Info)"
3+
description: "Describes the reason why SQL Server Migration Assistant (SSMA) for DB2 adds ROWID column to the table."
4+
author: "nahk-ivanov"
5+
ms.prod: sql
6+
ms.technology: ssma
7+
ms.devlang: "sql"
8+
ms.topic: "article"
9+
ms.date: "10/15/2020"
10+
ms.author: "alexiva"
11+
---
12+
13+
# DB22SS0028: `ROWID` column generated (Info)
14+
15+
This article describes the reason why SQL Server Migration Assistant (SSMA) for DB2 adds `ROWID` column to the table, if there are triggers.
16+
17+
## Background
18+
19+
In DB2 you can create a trigger that will run `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 DB2 trigger accesses both - `OLD` and `NEW` correlation names, 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.
20+
21+
## Example
22+
23+
Consider the following DB2 trigger, that executes for each row updated in `TRIG_TEST` table:
24+
25+
```sql
26+
CREATE OR REPLACE TRIGGER TSCHM.TRIG_TEST_AU
27+
AFTER UPDATE OF DATA ON TSCHM.TRIG_TEST
28+
REFERENCING OLD AS O NEW AS N
29+
FOR EACH ROW
30+
MODE DB2SQL
31+
BEGIN ATOMIC
32+
IF (N.DATA = 'ABC') THEN
33+
INSERT INTO TSCHM.TRIG_TEST(DATA) VALUES ('-' || O.DATA);
34+
END IF;
35+
END
36+
```
37+
38+
When you try to convert this trigger in SSMA, the following T-SQL will be produced within the SQL Server trigger:
39+
40+
1) Run a cursor over `inserted` row set, selecting `ROWID` and `DATA` columns into `@new$0` and `@new$DATA` variables:
41+
42+
```sql
43+
DECLARE
44+
ForEachInsertedRowTriggerCursor CURSOR LOCAL FORWARD_ONLY READ_ONLY FOR
45+
SELECT ROWID, DATA
46+
FROM inserted
47+
48+
OPEN ForEachInsertedRowTriggerCursor
49+
50+
FETCH ForEachInsertedRowTriggerCursor
51+
INTO @new$0, @new$DATA
52+
```
53+
54+
2) Select matching row from `deleted` row set into `@old$0` and `@old$DATA` variables, based on the inserted `ROWID` (stored in `@new$0` variable):
55+
56+
```sql
57+
SELECT @old$0 = ROWID, @old$DATA = DATA
58+
FROM deleted
59+
WHERE ROWID = @new$0
60+
```
61+
62+
3) Perform trigger actions using `@old$DATA`/`@new$DATA` variables:
63+
64+
```sql
65+
IF (@new$DATA = 'ABC')
66+
INSERT SSMAADMIN.TRIG_TEST(DATA)
67+
VALUES (('-' + ISNULL(@old$DATA, '')))
68+
```
69+
70+
## Additional information
71+
72+
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 **Off**, but during trigger conversion SSMA identifies that it requires a `ROWID` column, then [DB22SS0239](db22ss0239.md) conversion error will be generated.
73+
74+
## Related conversion messages
75+
76+
* [DB22SS0239: ROWID column not accessible](db22ss0239.md)
77+
* DB22SS0267: ROWID column
78+
* DB22SS0404: ROWID column can not be converted
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: "DB22SS0239: ROWID column not accessible (Error)"
3+
description: "Describes the reason why SQL Server Migration Assistant (SSMA) for DB2 requires a ROWID column to be defined."
4+
author: "nahk-ivanov"
5+
ms.prod: sql
6+
ms.technology: ssma
7+
ms.devlang: "sql"
8+
ms.topic: "article"
9+
ms.date: "10/15/2020"
10+
ms.author: "alexiva"
11+
---
12+
13+
# DB22SS0239: `ROWID` column not accessible (Error)
14+
15+
This article describes the reason why SQL Server Migration Assistant (SSMA) for DB2 requires a `ROWID` column to be defined for the table with triggers.
16+
17+
## Background
18+
19+
In DB2 you can create a trigger that will run `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 DB2 trigger accesses both - `OLD` and `NEW` correlation names, 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.
20+
21+
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 **Off**, then `ROWID` column will not be added to the table and SSMA will not be able to convert such triggers.
22+
23+
## Example
24+
25+
Consider the following DB2 trigger, that executes for each row updated in `TRIG_TEST` table:
26+
27+
```sql
28+
CREATE OR REPLACE TRIGGER TSCHM.TRIG_TEST_AU
29+
AFTER UPDATE OF DATA ON TSCHM.TRIG_TEST
30+
REFERENCING OLD AS O NEW AS N
31+
FOR EACH ROW
32+
MODE DB2SQL
33+
BEGIN ATOMIC
34+
IF (N.DATA = 'ABC') THEN
35+
INSERT INTO TSCHM.TRIG_TEST(DATA) VALUES ('-' || O.DATA);
36+
END IF;
37+
END
38+
```
39+
40+
When you try to convert this trigger in SSMA, if the **Generate ROWID column** project setting is **Off**, then SSMA will generate the following error message:
41+
42+
> DB22SS0239: ROWID column not accessible
43+
44+
## Possible remedies
45+
46+
Change the **Generate ROWID column** project setting to **On**, this will allow SSMA to produce the following T-SQL within the SQL Server trigger when converting the above example:
47+
48+
1) Run a cursor over `inserted` row set, selecting `ROWID` and `DATA` columns into `@new$0` and `@new$DATA` variables:
49+
50+
```sql
51+
DECLARE
52+
ForEachInsertedRowTriggerCursor CURSOR LOCAL FORWARD_ONLY READ_ONLY FOR
53+
SELECT ROWID, DATA
54+
FROM inserted
55+
56+
OPEN ForEachInsertedRowTriggerCursor
57+
58+
FETCH ForEachInsertedRowTriggerCursor
59+
INTO @new$0, @new$DATA
60+
```
61+
62+
2) Select matching row from `deleted` row set into `@old$0` and `@old$DATA` variables, based on the inserted `ROWID` (stored in `@new$0` variable):
63+
64+
```sql
65+
SELECT @old$0 = ROWID, @old$DATA = DATA
66+
FROM deleted
67+
WHERE ROWID = @new$0
68+
```
69+
70+
3) Perform trigger actions using `@old$DATA`/`@new$DATA` variables:
71+
72+
```sql
73+
IF (@new$DATA = 'ABC')
74+
INSERT SSMAADMIN.TRIG_TEST(DATA)
75+
VALUES (('-' + ISNULL(@old$DATA, '')))
76+
```
77+
78+
## Related conversion messages
79+
80+
* [DB22SS0028: ROWID column generated](db22ss0028.md)
81+
* DB22SS0267: ROWID column
82+
* DB22SS0404: ROWID column can not be converted

docs/ssma/db2/messages/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
- name: DB22SS0028
2+
href: db22ss0028.md
3+
- name: DB22SS0239
4+
href: db22ss0239.md
15
- name: DB22SS0573
26
href: db22ss0573.md
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: "O2SS0028: ROWID column generated (Info)"
3+
description: "Describes the reason why SQL Server Migration Assistant (SSMA) for Oracle adds ROWID column to the table."
4+
author: "nahk-ivanov"
5+
ms.prod: sql
6+
ms.technology: ssma
7+
ms.devlang: "sql"
8+
ms.topic: "article"
9+
ms.date: "10/15/2020"
10+
ms.author: "alexiva"
11+
---
12+
13+
# O2SS0028: `ROWID` column generated (Info)
14+
15+
This article describes the reason why SQL Server Migration Assistant (SSMA) for Oracle adds `ROWID` column to the table, if there are triggers.
16+
17+
## Background
18+
19+
In Oracle you can create a trigger that will run `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.
20+
21+
## Example
22+
23+
Consider the following Oracle trigger, that executes for each row updated in `TRIG_TEST` table:
24+
25+
```sql
26+
CREATE OR REPLACE TRIGGER TSCHM.TRIG_TEST_AU
27+
AFTER UPDATE OF DATA ON TSCHM.TRIG_TEST
28+
FOR EACH ROW
29+
BEGIN
30+
IF (:new.DATA = 'ABC') THEN
31+
INSERT INTO TSCHM.TRIG_TEST(DATA) VALUES ('-' || :old.DATA);
32+
END IF;
33+
END;
34+
```
35+
36+
When you try to convert this trigger in SSMA, the following T-SQL will be produced within the SQL Server trigger:
37+
38+
1) Run a cursor over `inserted` row set, selecting `ROWID` and `DATA` columns into `@new$0` and `@new$DATA` variables:
39+
40+
```sql
41+
DECLARE
42+
ForEachInsertedRowTriggerCursor CURSOR LOCAL FORWARD_ONLY READ_ONLY FOR
43+
SELECT ROWID, DATA
44+
FROM inserted
45+
46+
OPEN ForEachInsertedRowTriggerCursor
47+
48+
FETCH ForEachInsertedRowTriggerCursor
49+
INTO @new$0, @new$DATA
50+
```
51+
52+
2) In a loop, select matching row from `deleted` row set into `@old$0` and `@old$DATA` variables, based on the inserted `ROWID` (stored in `@new$0` variable):
53+
54+
```sql
55+
SELECT @old$0 = ROWID, @old$DATA = DATA
56+
FROM deleted
57+
WHERE ROWID = @new$0
58+
```
59+
60+
3) Perform trigger actions using `@old$DATA`/`@new$DATA` variables:
61+
62+
```sql
63+
IF (@new$DATA = 'ABC')
64+
INSERT SSMAADMIN.TRIG_TEST(DATA)
65+
VALUES (('-' + ISNULL(@old$DATA, '')))
66+
```
67+
68+
## Additional information
69+
70+
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 **Off**, but during trigger conversion SSMA identifies that it requires a `ROWID` column, then [O2SS0239](o2ss0239.md) conversion error will be generated.
71+
72+
## Related conversion messages
73+
74+
* [O2SS0239: ROWID column not accessible](o2ss0239.md)
75+
* O2SS0267: ROWID column
76+
* O2SS0404: ROWID column can not be converted
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: "O2SS0239: ROWID column not accessible (Error)"
3+
description: "Describes the reason why SQL Server Migration Assistant (SSMA) for Oracle requires a ROWID column to be defined."
4+
author: "nahk-ivanov"
5+
ms.prod: sql
6+
ms.technology: ssma
7+
ms.devlang: "sql"
8+
ms.topic: "article"
9+
ms.date: "10/15/2020"
10+
ms.author: "alexiva"
11+
---
12+
13+
# O2SS0239: `ROWID` column not accessible (Error)
14+
15+
This article describes the reason why SQL Server Migration Assistant (SSMA) for Oracle requires a `ROWID` column to be defined for the table with triggers.
16+
17+
## Background
18+
19+
In Oracle you can create a trigger that will run `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.
20+
21+
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 **Off**, then `ROWID` column will not be added to the table and SSMA will not be able to convert such triggers.
22+
23+
## Example
24+
25+
Consider the following Oracle trigger, that executes for each row updated in `TRIG_TEST` table:
26+
27+
```sql
28+
CREATE OR REPLACE TRIGGER TSCHM.TRIG_TEST_AU
29+
AFTER UPDATE OF DATA ON TSCHM.TRIG_TEST
30+
FOR EACH ROW
31+
BEGIN
32+
IF (:new.DATA = 'ABC') THEN
33+
INSERT INTO TSCHM.TRIG_TEST(DATA) VALUES ('-' || :old.DATA);
34+
END IF;
35+
END;
36+
```
37+
38+
When you try to convert this trigger in SSMA, if the **Generate ROWID column** project setting is **Off**, then SSMA will generate the following error message:
39+
40+
> O2SS0239: ROWID column not accessible
41+
42+
## Possible remedies
43+
44+
Change the **Generate ROWID column** project setting to **On**, this will allow SSMA to produce the following T-SQL within the SQL Server trigger when converting the above example:
45+
46+
1) Run a cursor over `inserted` row set, selecting `ROWID` and `DATA` columns into `@new$0` and `@new$DATA` variables:
47+
48+
```sql
49+
DECLARE
50+
ForEachInsertedRowTriggerCursor CURSOR LOCAL FORWARD_ONLY READ_ONLY FOR
51+
SELECT ROWID, DATA
52+
FROM inserted
53+
54+
OPEN ForEachInsertedRowTriggerCursor
55+
56+
FETCH ForEachInsertedRowTriggerCursor
57+
INTO @new$0, @new$DATA
58+
```
59+
60+
2) Select matching row from `deleted` row set into `@old$0` and `@old$DATA` variables, based on the inserted `ROWID` (stored in `@new$0` variable):
61+
62+
```sql
63+
SELECT @old$0 = ROWID, @old$DATA = DATA
64+
FROM deleted
65+
WHERE ROWID = @new$0
66+
```
67+
68+
3) Perform trigger actions using `@old$DATA`/`@new$DATA` variables:
69+
70+
```sql
71+
IF (@new$DATA = 'ABC')
72+
INSERT SSMAADMIN.TRIG_TEST(DATA)
73+
VALUES (('-' + ISNULL(@old$DATA, '')))
74+
```
75+
76+
## Related conversion messages
77+
78+
* [O2SS0028: ROWID column generated](o2ss0028.md)
79+
* O2SS0267: ROWID column
80+
* O2SS0404: ROWID column can not be converted

docs/ssma/oracle/messages/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
href: o2ss0007.md
33
- name: O2SS0021
44
href: o2ss0021.md
5+
- name: O2SS0028
6+
href: o2ss0028.md
57
- name: O2SS0029
68
href: o2ss0029.md
79
- name: O2SS0038
@@ -32,6 +34,8 @@
3234
href: o2ss0217.md
3335
- name: O2SS0221
3436
href: o2ss0221.md
37+
- name: O2SS0239
38+
href: o2ss0239.md
3539
- name: O2SS0245
3640
href: o2ss0245.md
3741
- name: O2SS0260

0 commit comments

Comments
 (0)