Thursday, March 31, 2011

How to un-confuse SQL Developer with ORA-00932

Sometimes SQL Developer will throw back a message like "ORA-00932: inconsistent datatypes: expected NUMBER got -". One way to get this is to try to execute

select collect(column_name) from user_tab_columns

The problem the tool is having is that it is getting back a data type which it doesn't recognize. 

If you don't already have a defined collection type, then go create one as they are really useful. This is mine

CREATE OR REPLACE TYPE TAB_CHAR IS table of VARCHAR2(4000);

Then you can do an explicit CAST in the select statement and the error will go away.

select cast(collect(column_name) as tab_char) from user_tab_columns


No comments: