views:

99

answers:

2

Hi,

I'm trying to run a query that has a few columns that are a CLOB datatype. If i run the query like normal, all of those fields just have (CLOB) as the value.

I tried using DBMS_LOB.substr(column) and i get the error

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

How can i query the CLOB column?

A: 

If you are using SQL*Plus try the following...

set long 8000

select ...
Scott
+1  A: 

When getting the substring of a CLOB column and using a query tool that has size/buffer restrictions sometimes you would need to set the BUFFER to a larger size. For example while using SQL Plus use the SET BUFFER 10000 to set it to 10000 as the default is 4000.

Running the DMBS_LOB.substr command you can also specify the amount of characters you want to return and the offset from which. So using DMBS_LOB.substr(column, 3000) might restrict it to a small enough amount for the buffer.

See oracle documentation for more info on the substr command

DBMS_LOB.SUBSTR (
   lob_loc     IN    CLOB   CHARACTER SET ANY_CS,
   amount      IN    INTEGER := 32767,
   offset      IN    INTEGER := 1)
  RETURN VARCHAR2 CHARACTER SET lob_loc%CHARSET;
mrjohn
I set restricted it to 3000 and it worked. Thanks!
Catfish