次の方法で共有


Migrating Oracle to SQL Server using SSMA - Error O2SS0160 SELECT statement not converted

By Bill Ramos and Mayank Bhanawat, Advaiya Inc.

This blog post describes why SQL Server Migration Assistant (SSMA) for Oracle doesn’t convert the SELECT statement in two scenarios that have ill formed ORDER BY clauses.

Error O2SS0160 SELECT statement not converted

Background

There are two scenarios, in which SSMA doesn’t convert the select statement and generate the same ‘Error O2SS0160 SELECT statement not converted’ due to following reason:

· When SELECT DISTINCT statement is used with CONNECT BY PRIOR statement in the hierarchical query, SSMA cannot convert the select statement.

· When ORDER BY clause sorts the result set based on the two columns/fields but you have specify only one column/field in SELECT statement, SSMA cannot convert the select statement

Possible Remedies

Scenario 1:

Consider the example below in which SELECT DISTINCT statement is used with CONNECT BY PRIOR statement in the hierarchical query.

SELECT distinct empno, MGR, ename

    FROM emp

START WITH MGR = 7902

CONNECT BY PRIOR MGR = empno;

 

When SSMA tries to convert the above code, it generates following error: Error O2SS0160 SELECT statement not converted”.

 

Error_O2SS0160

To resolve the above issue, you can use the ORDER BY statement in the source code of Oracle, as shown below:

SELECT distinct empno, MGR, ename

    FROM emp

START WITH MGR = 7902

CONNECT BY PRIOR MGR = empno

Order by empno;

When you execute the above query in SSMA, it converts successfully.

Scenario2: Consider the other example in which ORDER BY clause sorts the result set based on the two columns/fields but SELECT statement only have one columns/field.

Select Empno from emp ORDER BY 1, 2;

When SSMA tries to convert the above statement, it generates following Error O2SS0160 SELECT statement not converted”.

Error_O2SS0160_1

If the number of fields/columns used with ORDER BY clause is greater than number of field/column in the SELECT statement than SSMA generate the error. To solve this error either reduce the number of field/column in ORDER BY statement or equalize number of field/column in both SELECT statement and ORDER BY statement.

To solve this issue in our example, we equalize the field/column of SELECT statement with ORDER BY statement by removing the second column reference from the ORDER BY clause as shown below:

Select Deptno from emp ORDER BY 1;

When you execute the above code in SSMA, it converts successfully.

There are several other errors related to “Hierarchical query” that you may encounter. These include the following:

· Error O2SS0268: Hierarchical query with outer join cannot be converted

· Error O2SS0285: Hierarchical query was not converted

References

For more information, check out the following references:

· Migrating Oracle to SQL Server 2008 White Paper