Saturday, November 15, 2014

ORA-20001 is an invalid identifier

Weird error received while working with DBMS_STATS package...
Was working on implementing copy_table_stats using dbms_stats package for our partitioned tables and started getting this ORA-20001 partition_name is an invalid identifier.
I don't see any issue at all as the same code works great for other table partitions.
Only thing noticed is that the partition name given for the error-ed table is pure numeric.
But, I am defining a local variable with VARCHAR and storing the name into this local variable before using it in copy_table_stats proc so I would assume it wont be an issue.
Anyways, to overcome this issue I have to enclose this partition name with double quotes (" ") while passing on to copy_table_stats proc.

eg.,
dbms_stats.copy_table_stats(i.table_owner, i.table_name, chr(34)||t_prev_part_name||chr(34), chr(34)||i.partition_name||chr(34));

That took care of this issue.