Is it possible to find out the precision and scale of a numeric column? I have a PL\SQL script that determines the max length of each column in a table. The script contains an IF block that reads the max length of columns that are of data type NUMBER, VARCHAR2, CHAR or any other data type. I would like to write the new PL\SQL statements within the ELSIF MyDataType = 'NUMBER' block to handle it. Some of the columns will have a precision and scale but will not have decimal data in it. So, I would like to check for that as well. This is just a small piece of the PL\SQL code.
Code:
IF MyDataType = 'VARCHAR2' THEN
dbms_output.put_line (
'SELECT ' || '''' || MyCol || '''' || ',' || '''' || MyDataType || '''' || ',' || ' ' || '''' || '(' || '''' || ',' || 'max(length (' || MyCol || ')) as max' || ', ' || '''' || '), ' || '''' || ' FROM SUM070_DEMOGRAPHIC;' );
ELSIF MyDataType = 'NUMBER' THEN
dbms_output.put_line (
'SELECT ' || '''' || MyCol || '''' || ',' || '''' || MyDataType || '''' || ',' || ' ' || '''' || '(' || '''' || ',' || 'max(length (' || MyCol || ')) as max' || ', ' || '''' || '), ' || '''' || ' FROM SUM070_DEMOGRAPHIC;' );
ELSIF MyDataType = 'CHAR' THEN
dbms_output.put_line (
'SELECT ' || '''' || MyCol || '''' || ',' || '''' || MyDataType || '''' || ',' || ' ' || '''' || '(' || '''' || ',' || 'max(length (' || MyCol || ')) as max' || ', ' || '''' || '), ' || '''' || ' FROM SUM070_DEMOGRAPHIC;' );
ElSE
dbms_output.put_line (
'SELECT ' || '''' || MyCol || '''' || ',' || '''' || MyDataType || '''' || ', ' || '''' || ',' || '''' || ' FROM SUM070_DEMOGRAPHIC WHERE rownum = 1;' );
END IF;