Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle long field attribute - length

Re: Oracle long field attribute - length

From: Ari Kaplan <akaplan_at_interaccess.com>
Date: 1997/08/05
Message-ID: <5s7fh1$sgj@nntp.interaccess.com>#1/1

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)

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:                      <->
<->                                                               <->
<->             http://homepage.interaccess.com/~akaplan          <->
<->                                                               <->
<->             email: akaplan_at_interaccess.com                    <->

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
Received on Tue Aug 05 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US