Skip to Main Content
  • Questions
  • ORA-02070: database does not support ROWIDs in this context

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Sumaj.

Asked: July 29, 2020 - 7:59 am UTC

Last updated: July 29, 2020 - 10:23 am UTC

Version: 19C

Viewed 1000+ times

You Asked

We have a Business case to migrate Oracle 19C from 11G, and one of our batch job is failing with the below error after the migration to Engineering environment.

ORA-02070: database  does not support ROWIDs in this context


Existing query in our business logic is using rowid in the order by clause associated with ref cursor and if we remove the rowid from the sorting the query is working, but the same query is working without any issues in 11G.
We don't have any other reliable column in the table for the sorting, we tried without rowid and resulted in incorrect output.

Sample sql snippet:

select * from table 
(test_pgk.transform_test 
(cursor 
( 
select code,text from test_1 t order by code,rowid 
)))


You can refer more details in livesql

A quick help would be highly appreciated.

with LiveSQL Test Case:

and Chris said...

I'm not sure how you had this working in 11g.

Stripping down to the cursor expression in 11.2.0.4 gives me:

create table test_1 (code number, text varchar2(100));
insert into test_1 values (1,'t1');
insert into test_1 values (2,'t2');
insert into test_1 values (3,'t3');

select * from v$version;

BANNER                                                                         
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production    
PL/SQL Release 11.2.0.4.0 - Production                                          
CORE 11.2.0.4.0 Production                                                      
TNS for Linux: Version 11.2.0.4.0 - Production                                  
NLSRTL Version 11.2.0.4.0 - Production  

select     
  cursor  ( 
      select code,text
      from   test_1 t 
      order by code, rowid 
    ) 
from dual;

ORA-03001: unimplemented feature
ORA-02070: database  does not support ROWIDs in this context


The key error is the first one: ORA-03001: unimplemented feature. It seems ordering by rowid in a cursor expression is not supported! If you insist on doing this, you'll need to take this up with support to get this added.

In general ordering by rowid is unsafe. Various actions can change the rowid of a row, so this isn't guaranteed to give you rows in the same order every time.

We don't have any other reliable column in the table for the sorting

Is there no primary/unique key on the table?

To be sure of always getting rows in the same order, adding PK/UC columns to the end of the sort will ensure everything returns in the same sequence.

If your table doesn't have a PK/UC... you've probably got bigger things to worry about anyway.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.