Professional Documents
Culture Documents
Converting CLOBs 2 VARCHAR
Converting CLOBs 2 VARCHAR
Converting CLOBs 2 VARCHAR
Surrinder -- Thanks for the question regarding "Converting CLOBS TO VARCHAR", version 8.1.7
Submitted on 15-Mar-2001 11:11 Eastern US time Tom's latest followup | Bookmark | Bottom
Last updated 21-Oct-2008 12:08
You Asked
Can you give me a solution for converting CLOBS datatype to VARCHAR datatypes, all the
documents I refer to talk about converting BLOBS to VARCHAR and when I try and apply the
examples to CLOBS, get errors
and we said...
for example:
will get me the first 4000 bytes of the clob. Note that when using SQL as I did, the max
length is 4000. You can get 32k using plsql:
declare
my_var long;
begin
for x in ( select X from t )
loop
my_var := dbms_lob.substr( x.X, 32000, 1 );
....
Reviews
Converting CLOBS TO VARCHAR March 16, 2001 - 7am US/Eastern Bookmark | Bottom | Top
Reviewer: Surrinder Singh from UK
Extremely useful all the documentation that refered to LOB conversions in the ORACLE Docs , and
that stated that the dbms_lob.substr should be returned into a RWS(32767), not a LONG for CLOBS,
thanks once again.
Converting CLOBS TO VARCHAR March 16, 2001 - 3pm US/Eastern Bookmark | Bottom | Top
Reviewer: Naveen from Raleigh,NC
Converting CLOBS TO VARCHAR March 16, 2001 - 3pm US/Eastern Bookmark | Bottom | Top
Reviewer: Naveen from Raleigh,NC
How to display long data after <xml> tag in text file via sql*plus? June 5, 2001 - 2pm US/Eastern
Bookmark | Bottom | Top
1 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
Dear Tom,
How does one display a long datatype column variable of a table on the same line after an xml tag?
For example, we are using sql*plus to write a file containing xml tags at the beginning of each
record via a SELECT statement. I get "inconsistent datatypes" when I try to write out the long
variable.
My goal is to get the long variable written on the same line as the <DESC> tag with NO spaces
between the <DESC> and the text data, as this output will serve as a template to XML processing.
Any help you can provide me is greatly appreciated. I just started using sql*plus about a week
ago, and I'm having fun with it. I've looked at using the ConText option, but my co-worker thinks
there's an easier way of displaying this information then using ConText.
Sincerely,
Teresa Felch
teresf@bellsouth.net
very good June 25, 2001 - 5pm US/Eastern Bookmark | Bottom | Top
Reviewer: Satya K from San Francisco, CA USA
This means, Oracle cursor can not have any column more than 4000 chars width..
Converting CLOBS TO VARCHAR March 18, 2002 - 5pm US/Eastern Bookmark | Bottom | Top
Reviewer: Karl Bergerson from Bellevue WA USA
dbms_lob.substr problem June 10, 2003 - 7am US/Eastern Bookmark | Bottom | Top
Reviewer: A reader
Hi
declare
res varchar2(32767);
begin
select dbms_lob.substr(col,dbms_lob.getlength(col),1) into res from lobsq;
dbms_output.put_line(res);
end;
2 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
dbms_output.put_line has a documented limit of 255 characters/line. you have exceeded that.
is a little dump routine I use. Furthermore, SQL is limited to returning 4000 characters from
VARCHAR types.
Table created.
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV> declare
2 l_data long;
3 l_clob clob;
4 begin
5 l_data := rpad( '*', 4245, '*' );
6 insert into t values ( empty_clob() )
7 returning x into l_clob;
8 dbms_lob.writeAppend( l_clob, 4245, l_data );
9 end;
10 /
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV> select dbms_lob.getLength(x) from t;
DBMS_LOB.GETLENGTH(X)
---------------------
4245
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV> declare
2 l_data varchar2(10000);
3 begin
4 select dbms_lob.substr(x,4245,1) into l_data from t;
5 dbms_output.put_line( 'length = ' || length(l_data) );
6 end;
7 /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 1
ORA-06512: at line 4
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV> declare
2 l_data varchar2(10000);
3 l_clob clob;
4 begin
5 select x into l_clob from t;
6 l_data := dbms_lob.substr( l_clob, 4245, 1 );
7 dbms_output.put_line( 'length = ' || length(l_data) );
8 end;
9 /
length = 4245
3 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
Very weird behaviour if LONG columns were imported from ACCESS. October 21, 2004 - 4pm US/Eastern
Bookmark | Bottom | Top
Reviewer: Ken Chiu from Canada
I used ms-Access to import a table into oracle, the table consists of a Access data type of memo,
which is mapped to Long during the import.
Now to do a describe on this imported table, I need to surround the tablename with double quotes:
SQL> desc Day1_1A1_1A4;
ERROR:
ORA-04043: object Day1_1A1_1A4 does not exist
Then when I wanted to convert the column from LONG to CLOB, I need to have the correct casing for
the column name..ie.
However, noticed the first letter in the column name is now upper cased :
Table altered.
That's question#2, what caused this case sensitvity. I know this probably have to do with the
importing from Access, but please advise from an Oracle's perspective what's happening. Thanks Tom
!
Ken.
in Access, you created the table with that case of name - they "kept" it when it moved to Oracle.
You need to use their exact case.
converting LONG to Varchar2 February 9, 2005 - 6pm US/Eastern Bookmark | Bottom | Top
Reviewer: Frank
Hi Tom,
I am connected to:
Oracle8 Enterprise Edition Release 8.0.5.0.0 - Production
With the Partitioning and Objects options
PL/SQL Release 8.0.5.0.0 - Production
I have 2 tables, one which has survey info and other which has text for questions (which is a LONG
field). I want to unload the data by joining the 2 tables but always get this error:
select question_id||','||q1.text
from survey s, questions_text q1
where s.question_id = q1.qkey(+)
/
select question_id||','||q1.text
*
ERROR at line 1:
ORA-00932: inconsistent datatypes
4 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
The TEXT column in questions_text table is of LONG datatype. How can I get this data unloaded?
Please help.
Thanks.
Thanks for your answer Tom but here is the next question.
The data entered in the field is all formatted, with carriage returns. How can I get rid of that?
Because this CSV file is going to be loaded into other database using some loading tool. Hence I
want the data in one continous string.
Thanks in advance.
what other database (i've worked with lots of them) wants that???????
I mean, there are other fields alongwith this long field. This long field has data entered into it
with carriage returns. Of course, every row will have the carriage return. I just want to get rid
of the carriage returns in the long field.
what is this other database? In Oracle we would just unload the data
"hello","world","This has
line breaks
in it","5"|
"hello","world","This has
line breaks
in it","5"|
and use an end of record terminator of "|\n" upon reload. no data loss (you'll lose CR's)
Using function or PL/SQL for above February 23, 2005 - 4pm US/Eastern Bookmark | Bottom | Top
Reviewer: A reader
Tom,
With continuation to the above problem, I wrote a function to convert the long to string (with the
help of one of your functions). Using the substr function, is there any limit to return the
string?
5 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
Now I pass the rowid for each row and get the data. Is this the correct way or some other better
method?
Thanks.
rowid will be the fastest path back to the long, you could use primary key but that would be an
index range scan+table access by index rowid, rowid will just be "table access by rowid"
ERROR:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 1
select long2str(rowid)
from questions_text
where question_id < 100;
Now I fear by reducing from 32k to 4000 will I lose any data from the fields.
yes you will lose - but you cannot get over 4,000 bytes in SQL, it is just the way SQL is -- longs
are longs, sql is sql, the limit of varchar2 is 4,000 bytes.
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:510622111991#29261383968124
clob in pl/sql July 28, 2006 - 3am US/Eastern Bookmark | Bottom | Top
Reviewer: A reader
6 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
begin
for i in (select * from SQLTEXT_FULL where rownum < 2)
loop
execute immediate 'explain plan set statement_id =''' || i.qid || ''' for ' ||
i.sql_text;
end loop;
end;
/
in 9.2.0.6
-----------
ERROR at line 4:
ORA-06550: line 4, column 36:
PLS-00382: expression is of wrong type
ORA-06550: line 4, column 12:
PL/SQL: Statement ignored
in 8.1.7.4:
-------------
ERROR at line 4:
ORA-06550: line 4, column 36:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 4, column 12:
PL/SQL: Statement ignored
why would you not use the real plans - which are stored in v$sql_plan
You'll literally KILL your system by running an explain plan on every query.
That, and you'll not get the real plans (explain plan cannot bind variable peek, explain plan
cannot tell the bind datatype, explain plan will get the wrong answer)
and in 8i, just skip it, since v$sql_plan doesn't exist. You'll not be getting the right
information.
clob in pl/sql July 29, 2006 - 12pm US/Eastern Bookmark | Bottom | Top
Reviewer: A reader
Hi
We are using RULE optimizer so I dont mind get the explain plan. Also i am not running on
production, I a running in a replicated environment (using split mirror technology) which are used
for these purposes.
Your comments is interesting however, we are migrating from 8i to 9i and we want to check all
execution plan changes. If in 8i Explain plan is not valid then how could we accomplish our goal?
Our queries use to_date accordingly so I guess the "explain plan cannot tell the bind datatype"
does not apply?
clob in pl/sql July 30, 2006 - 5am US/Eastern Bookmark | Bottom | Top
Reviewer: A reader
Hi
We do bind numbers, if explain plan has such limitations what is it used for....???
7 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
Table created.
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> variable x number
ops$tkyte%ORA10GR2> alter session set sql_trace=true;
Session altered.
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 3826520415
----------------------------------------------------
| Id | Operation | Name |
----------------------------------------------------
| 0 | SELECT STATEMENT | |
| 1 | TABLE ACCESS BY INDEX ROWID| T |
|* 2 | INDEX UNIQUE SCAN | SYS_C0012505 |
----------------------------------------------------
2 - access("X"=:X)
Note
-----
- rule based optimizer used (consider using cbo)
because the explain plan said ":x is a varchar2", it thinks the index is OK to use, however, tkprof
shows reality:
8 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
Table created.
1 row created.
ops$tkyte%ORA9IR2> commit;
Commit complete.
Table altered.
1 row updated.
Table altered.
Table altered.
ops$tkyte%ORA9IR2> desc t;
Name Null? Type
---------------------------------------- -------- ----------------------------
X CLOB
Is this a bug? February 13, 2007 - 6pm US/Eastern Bookmark | Bottom | Top
Reviewer: Su Baba
I tried to do the above suggestion using a PL/SQL block, but was not able to do it. Anyway to get around this problem?
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
PL/SQL Release 10.2.0.2.0 - Production
CORE 10.2.0.2.0 Production
TNS for 32-bit Windows: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production
5 rows selected.
SQL>
SQL> CREATE TABLE x (
2 col1 VARCHAR2(1000)
3 );
Table created.
SQL>
SQL>
SQL> BEGIN
2 FOR x IN (SELECT COUNT(*) cnt
3 FROM user_tab_columns
4 WHERE table_name = 'X' AND
5 column_name = 'COL1' AND
6 data_type = 'CLOB')
7 LOOP
8 IF (x.cnt = 0) THEN
9 EXECUTE IMMEDIATE 'ALTER TABLE X ADD col2 CLOB';
10
11 UPDATE x
12 SET col2 = Col1;
13
14 EXECUTE IMMEDIATE 'ALTER TABLE x DROP COLUMN col1';
15 EXECUTE IMMEDIATE 'ALTER TABLE x RENAME COLUMN col2 TO col1';
16 END IF;
17 END LOOP;
18 END;
19 /
SET col2 = Col1;
*
ERROR at line 12:
ORA-06550: line 12, column 17:
PL/SQL: ORA-00904: "COL2": invalid identifier
ORA-06550: line 11, column 10:
PL/SQL: SQL Statement ignored
9 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
SQL>
SQL> desc x
Name Null? Type
----------------------------------------------------------------------- -------- --------------
COL1 VARCHAR2(1000)
SQL>
SQL>
SQL> -- -----------------------------------------------------
SQL> -- Same code but comment out a big portion of it
SQL> -- -----------------------------------------------------
SQL> BEGIN
2 FOR x IN (SELECT COUNT(*) cnt
3 FROM user_tab_columns
4 WHERE table_name = 'X' AND
5 column_name = 'COL1' AND
6 data_type = 'CLOB')
7 LOOP
8 IF (x.cnt = 0) THEN
9 EXECUTE IMMEDIATE 'ALTER TABLE X ADD col2 CLOB';
10 /*
11 UPDATE x
12 SET col2 = Col1;
13
14 EXECUTE IMMEDIATE 'ALTER TABLE x DROP COLUMN col1';
15 EXECUTE IMMEDIATE 'ALTER TABLE x RENAME COLUMN col2 TO col1';
16 */
17 END IF;
18 END LOOP;
19 END;
20 /
SQL>
SQL>
SQL> desc x
Name Null? Type
----------------------------------------------------------------------- -------- --------------
COL1 VARCHAR2(1000)
COL2 CLOB
you would have to perform the update using dynamic sql as well.
how to convert clob filed to varchar2 filed February 28, 2007 - 9pm US/Eastern Bookmark | Bottom | Top
Reviewer: Amao from China
I have one procedure whose function is to generate dynamic statemetn for materialized view.
for example:
execute immediate l_sqlstmt; l_sqlstmt is clob field whose lenght is almost 72k.
As you know, Varchar2 variable only store 32k data. So I can not define l_sqlstmt as varchar2.
dbms_sql can take a plsql table type in the parse call - and that can be larger than 32k.
March 1, 2007 - 5pm US/Eastern Bookmark | Bottom | Top
Reviewer: michaels from Germany
> right now, execute immediate is 32k - period.
10 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
SQL> DECLARE
stmt1 LONG;
stmt2 LONG;
BEGIN
stmt1 := 'BEGIN null; ' || LPAD (' ', 32000, ' ');
stmt2 := RPAD (' ', 32000, ' ') || ' END;';
DBMS_OUTPUT.put_line ('Statement length: ' || LENGTH (stmt1 || stmt2));
it will in general fail - don't go over 32k, it'll just not work at the worst possible times.
BEGIN
n := dbms_lob.getlength(s);
m := LENGTH(DBMS_LOB.SUBSTR(s));
IF n < 32767 THEN
EXECUTE IMMEDIATE DBMS_LOB.SUBSTR(s);
ELSIF n < 64000 THEN
EXECUTE IMMEDIATE DBMS_LOB.SUBSTR(s, 32000, 1)||DBMS_LOB.SUBSTR(s, n-32000, 32001);
ELSE
dbms_output.put_line('ERR('||v_prg||'): skipped');
END IF;
END;
/
The m returns 8191 even n > 10000 in 10.2.0.3 Oracle instance on Solaris 10. It returns correct
length in a instance on Window 2003. Why? How to correct it?
prior to 11g, execution of SQL dynamically - using native dynamic sql - that is greater then 32k is NOT SUPPORTED - does not work. If
you've gotten it to work by accident here and there - DO NOT RELY on it. It is explicitly "not a feature"
You have to use DBMS_SQL and the parse interface that takes a plsql table - in 10gr2 and before THAT IS THE ONLY way - the ONLY
way - to execute dynamic sql in plsql larger than 32k.
So, not even going to address the original request - you just cannot do what you are doing - period.
dbms_lob.substr returns different length in two oracle instances April 4, 2008 - 10am US/Eastern
Bookmark | Bottom | Top
Reviewer: htu from NJ USA
dbms_lob.substr returns different length in two oracle instances April 4, 2008 - 1pm US/Eastern
Bookmark | Bottom | Top
Reviewer: htu from NJ USA
DECLARE
11 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
s CLOB;
s1 LONG;
s2 LONG;
n NUMBER;
BEGIN
dbms_lob.createtemporary(s, TRUE);
dbms_lob.open(s, dbms_lob.lob_readwrite);
s1 := 'BEGIN null; ' || LPAD (' ', 32000, ' ');
n := length(s1||' END;'); dbms_lob.writeappend(s, n, s1||' END;');
exec_now(s,5);
dbms_lob.close(s);
dbms_lob.createtemporary(s, TRUE);
dbms_lob.open(s, dbms_lob.lob_readwrite);
-- n := dbms_lob.getlength(s); dbms_lob.erase(s, n, 1);
n := length(s1); dbms_lob.writeappend(s, n, s1);
s2 := RPAD (' ', 12000, ' ') || ' END;';
n := length(s2); dbms_lob.writeappend(s, n, s2);
exec_now(s,5);
dbms_lob.close(s);
END;
/
dbms_lob.substr returns different length in two oracle instances April 4, 2008 - 1pm US/Eastern
Bookmark | Bottom | Top
Reviewer: htu from NJ USA
I used the above test code, and here are the different outputs:
because all of your code must be erased. did you not read what I wrote. You cannot - CANNOT - use native dynamic sql with strings
exceeding 32k in 10gr2 and before
Sorry, I did not make it clear. I just want to test if it really works if it exceeds 32k. My
question is why it only returns 8191 characters in Solaris 10 Oracle 10gR2? Is there a parameter
setting the limit? I compare the PL/SQL setting in both instances. They are the same.
12 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
nope, I don't believe you - you posted code that clearly - CLEARLY - shows what you are doing.
using dbms_lob.substr() the way you are is just silly, I don't get it, just call dbms_lob.get_length and be done with it, calling
dbms_lob.substr in this case is not useful at all.
I'm not even going to bother looking at this - you are doing something that just isn't going to work - so stop it.
DBMS_LOB April 5, 2008 - 4pm US/Eastern Bookmark | Bottom | Top
Reviewer: A reader
dbms_lob.substr returns different length in two oracle instances April 7, 2008 - 10am US/Eastern
Bookmark | Bottom | Top
Reviewer: htu from NJ USA
I was just following michael's example to test Oracle's limit on 'execute immediate'. Curiosity
leads to discovery.
This is fine if you do not want to look deeper into this. But I still want to report my finding:
dbms_lob.substr returns 8k in all my Oracle instances on Solaris servers while it returns the
default 32k on all Oracle instances on Window servers. The Oracle versions I tested are 9.2.0.1,
9.2.0.8, and 10.2.0.3. Here is the code:
DECLARE
s CLOB;
s1 LONG;
s2 LONG;
n NUMBER;
m NUMBER;
BEGIN
dbms_lob.createtemporary(s, TRUE);
dbms_lob.open(s, dbms_lob.lob_readwrite);
s1 := 'BEGIN null; ' || LPAD (' ', 32000, ' ')||' END;';
n := length(s1); dbms_lob.writeappend(s, n, s1);
m := LENGTH(DBMS_LOB.SUBSTR(s));
dbms_output.put_line('N='||TO_CHAR(n)||','||'M='||TO_CHAR(m));
dbms_lob.close(s);
END;
/
the default is supposed to be 32k, it would be a 'bug' if it returns 8k. Please utilize support (although I personally think the default should
just be removed, it doesn't make sense to have a default substr length)
April 24, 2008 - 12pm US/Eastern Bookmark | Bottom | Top
Reviewer: Milo van der Leij from MI, USA
dbms_lob.substr, according to the 11g documentation, returns at most a substring of length (32767/n), where n is the (maximum)
byte-width for the character set.
dbms_lob.substr is returning at most 8191 (8k - 1) characters for me since I'm using AL32UTF8, which has a max byte-width of 4 bytes per
character, and 32767/4 = 8191.75.
Similar restrictions apparently exist when converting (both implicitly and explicitly) CLOBs to VARCHAR2s. The following fails unless the
number is reduced to 8191, even when s is defined as VARCHAR2(32767 BYTE):
Why all this is, I do not know. At least the dbms_lob.substr thing is documented.
ahh, i did not even think about that - the characterset, of course, that makes total sense (the os was a red herring entirely)
June 17, 2008 - 4pm US/Eastern Bookmark | Bottom | Top
Reviewer: A reader
CLOB to VARCHAR over DBLink ??? September 22, 2008 - 2pm US/Eastern Bookmark | Bottom | Top
Reviewer: Jack from Atlanta,GA
13 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
is the substring function valid over a database link to a remote CLOB field ?
you would typically want to use the remote dbms_lob package - select dbms_lob.substr@remote( ... )
CLOB select over db link using DBMS_LOB pkg October 10, 2008 - 12pm US/Eastern Bookmark | Bottom | Top
Reviewer: Jack from Atlanta, GA
SQL> /
select dbms_lob.substr@dblink_qaremedy(notes,1,50) from sprt_service_request@dblink_qaremedy
*
ERROR at line 1:
ORA-22992: cannot use LOB locators selected from remote tables
confirmed, that used to work - not sure if that is a bug or not, I'll file one to see.
In the meanwhile if you create a view on the remote site - that does definitely work.
DBMS_SQL cursor to Dynamic cursor in 10g ? October 14, 2008 - 10pm US/Eastern Bookmark | Bottom | Top
Reviewer: Kiran from South Bend,IN
Hi Tom,
Since we are discussing about CLOB in this page.. i got a question. I have learnt from this page
that dbms_sql is better to dynamically execute CLOB fields and i want to know if there is a way to
return dynamic cursor instead of dbms_sql cursor in oracle 10gR2. I see that in Oracle 11g we have
to_refcursor function .. but i dont see any similar function in Oracle10gR2 ... is there a work
around ?
there is not.
CLOB in WHERE October 16, 2008 - 7am US/Eastern Bookmark | Bottom | Top
Reviewer: KK from SBN,IN
Hi Tom,
Thanks for the reply.I have a requirement ..where a CLOB is passed as input to stored proc. I
need to use this parameter in where condition and return a refcursor/dynamic cursor/pl/sql cursor
to the calling application.
I do not know if there is any other way to do it other than using dbms_sql.And if i use dbms_sql i
cannot return a dynamic cursor.And i cannot use EXEC IMMEDIATE as CLOB parameter is more than 32k
size.
I tried using GLOBAL TEMPORARY TABLE as a temporary table to store the resultant data and then use
OPEN FOR on the GTT, but since we are using coonection pooling .. this doesn't work either. Any
ideas ?
if the clob plus the rest of the query exceeds 32k, you will not be doing this in 10g and before using plsql.
connection pooling should not affect the use of a global temporary table at all here - you would be processing the entire result in a single
connection pool grab - not across pages (if a ref cursor could work - BY DEFINITION a global temporary table can work - they are both
'private' to a connection)
for CLOB using GTT in Connection Pooling October 20, 2008 - 11am US/Eastern
14 of 15 23.10.2008 7:16
Ask Tom "Converting CLOBS TO VARCHAR" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION...
Hi Tom,
but, in a connection pool environment - perhaps using session based gtt's would be an all around
bad idea from the very beginning.
----------------------
So if i am using session based GTT's to generate a dynamic cursor in a .Net connection pooling
environment .. then will it not cause a problem? In your review to previous question you said GTT's
are independent and should not cause a problem in connection pooling.
a) I grab a connection
b) I populate gtt
c) I give connection back
d) You grab connection and get the one I got in a)
That said, if you use a global temporary table (transaction based, commit or rollback and poof - data disappears) it is connection pool 'safe'
since you would NEVER give a connection back without resolving the transaction that is in place. You would finish your transaction.
So, if you can use a cursor that is returned to the client - you can in fact use a global temporary table. The client would exhaust the cursor,
the client would exhaust the global temporary table.
Write a Review
All information and materials provided here are provided "as-is"; Oracle disclaims all express and implied warranties, including, the implied warranties of merchantability or fitness
for a particular use. Oracle shall not be liable for any damages, including, direct, indirect, incidental, special or consequential damages for loss of profits, revenue, data or data
use, incurred by you or any third party in connection with the use of this information or these materials.
15 of 15 23.10.2008 7:16