How do I check a column type with a cursor?
I need to query an Oracle database table and check the datatype of a column. I got as far as the below script but TYPE_NAME is not recognised. I can check the contents of the column but I need to check the actual type of the table.
Anyone know how I can do that?
set pagesize 1000;
variable errorCode number;
DECLARE
cursor c1 is
select theColumn from myDatabaseTable;
colRec c1%ROWTYPE;
BEGIN
:errorCode := 0;
OPEN c1;
FETCH c1 INTO colRec;
IF colRec.TYPE_NAME <> 'CHAR' THEN
:errorCode := 1;
END IF;
CLOSE c1;
END;
/
exit :errorCode;