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.
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
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
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”.
To resolve the above issue, you can use the ORDER BY statement in the source code of Oracle, as shown below:
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”.
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
For more information, check out the following references:
· Migrating Oracle to SQL Server 2008 White Paper