ORA-00932: inconsistent datatypes: expected - got LONG
This post is dedicated to one of the most elusive errors I've encountered.
I haven't been able to replicate the issue from my notes at the time, so this summary is from memory.
Hopefully this will help anyone else (or future me) that comes across this one.
The scenario:
Query a readonly 9i db from 11g via dblink.
Queries kept erroring with ORA-00932. None of the columns I was looking at were long.
All columns involved were either number, varchar2, or date.
Trial and error confirmed the issue was one of the varchar2 columns. None of which were longer than 4000 characters.
Substr didn't fix the issue.
The fix was to wrap nvl() around the varchar2 columns, to make sure none of them came back with nulls.
Some combination of the different db versions, read-only db and the dblink confused the database to the point that it didn't know what data type was coming back when it encountered nulls.
Suspicion is it only happened if the null was in the first row that returned.
Unclear if NLS settings were a factor.
I haven't been able to replicate the issue from my notes at the time, so this summary is from memory.
Hopefully this will help anyone else (or future me) that comes across this one.
The scenario:
Query a readonly 9i db from 11g via dblink.
Queries kept erroring with ORA-00932. None of the columns I was looking at were long.
All columns involved were either number, varchar2, or date.
Trial and error confirmed the issue was one of the varchar2 columns. None of which were longer than 4000 characters.
Substr didn't fix the issue.
The fix was to wrap nvl() around the varchar2 columns, to make sure none of them came back with nulls.
Some combination of the different db versions, read-only db and the dblink confused the database to the point that it didn't know what data type was coming back when it encountered nulls.
Suspicion is it only happened if the null was in the first row that returned.
Unclear if NLS settings were a factor.
Note to self: Next time check odbc settings: VarMaxAsLong and HS_KEEP_REMOTE_COLUMN_SIZE odbc parameters
ReplyDelete