Click to See Complete Forum and Search --> : How to get the maximum length of a column with datatype long?


ssmith
07-18-2002, 10:24 AM
How do I get the maximum length or size of a column with a datatype long?
select vsize(select_string) from table

returns:
ERROR at line 1:
ORA-00997: illegal use of LONG datatype
Thanks.

Shestakov
07-18-2002, 03:22 PM
u have to use dbms_lob.getlength function.

SQL> select dbms_lob.getlength(text) from how_to_.....readlob;

DBMS_LOB.GETLENGTH(TEXT)
------------------------
28

ssmith
07-22-2002, 06:44 AM
SQL> select dbms_lob.getlength(select_string) from output_table;
select dbms_lob.getlength(select_string) from output_table
*
ERROR at line 1:
ORA-00997: illegal use of LONG datatype

I know you need to use UTL_RAW, but how do I get the maximum for the table? and How do I get the size in Bytes? Thanks.

ssmith
07-22-2002, 07:07 AM
I have found the solution if anyone is interested:
DECLARE
vRaw number;
v_max_len number;

CURSOR a1 is
SELECT select_string
FROM output_table;

BEGIN
vRaw :=0;
v_max_len := 0;

FOR arec in a1 LOOP

vRaw := utl_raw.length(arec.select_string);

if vRaw > v_max_len then
v_max_len := vRaw;
end if;

END LOOP;
dbms_output.put_line('Max Length is '||v_max_len);
END;
/