Pages

Tuesday, May 28, 2024

View Partition High value - Avoid ORA-00932: inconsistent datatypes

SELECT partition_name, TO_CHAR(high_value) 
  FROM USER_TAB_PARTITIONS
 WHERE table_name = 'SOME_PARTITIONED_TABLE';
ORA-00932: inconsistent datatypes: expected CHAR got LONG

SELECT partition_name, TO_CHAR(TO_LOB(high_value))
  FROM USER_TAB_PARTITIONS
 WHERE table_name = '
SOME_PARTITIONED_TABLE';
ORA-00932: inconsistent datatypes: expected - got LONG

The Solution would be to create a temporary table.

CREATE TABLE TEMP_PARTITION_NAMES AS 
SELECT partition_name, TO_LOB(high_value) high_value
  FROM USER_TAB_PARTITIONS
 WHERE table_name = 'SOME_PARTITIONED_TABLE';

SELECT partition_name, TO_CHAR(high_value)
  FROM TEMP_PARTITION_NAMES 
 ORDER BY TO_CHAR(high_value);

DROP TABLE TEMP_PARTITION_NAMES;

No comments:

Post a Comment