Subject: Re: Oracle long field attribute - length
Newsgroups: comp.databases.oracle.misc
References: <33E61B34.7093@mit.edu>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

Steven Neiterman (wade@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@mit.edu)
Steven,

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:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page .htm">Back to Ari Kaplan's Home Page