Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle long field attribute - length
Steven Neiterman (wade_at_mit.edu) wrote:
: Anyone know of a way to determine the length of an attribute defined as : a long? : The length function does not work with the long attribute. : Thanks in advance, : ..Steve : (wade_at_mit.edu)
You cannot do string functions on LONG columns with regular SQL. You will have to use PL/SQL. Look at the following example:
SET SERVEROUTPUT ON SIZE 10000;
DECLARE
long_var LONG;
BEGIN
SELECT text_column INTO long_var
FROM table_with_long
WHERE rownum < 2;
DBMS_OUTPUT.PUT_LINE('The length is '||LENGTH(long_var));
END;
/
Basically, you define a variable as the LONG type, then SELECT the column INTO the variable. Finally, it is output to the user. SET SERVEROUTPUT ON SIZE 10000 allows spooling from the PUT_LINE to go to the screen.
-Ari Kaplan
Independent Oracle DBA Consultant
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page: <-> <-> <-> <-> http://homepage.interaccess.com/~akaplan <-> <-> <-> <-> email: akaplan_at_interaccess.com <->
![]() |
![]() |