解决oracle 10g sql *plus 用dbms_output.put_line()输出时的长度限制问题 ORA-20000: ORU-10028: line le

解决oracle 10g
sql *plus 用dbms_output.put_line()输出时的长度限制问题。。。。。

错误提示:

*
第 1 行出现错误:
ORA-20000: ORU-10028: line length overflow, limit of 255 chars per line
ORA-06512: 在 "SYS.DBMS_OUTPUT", line 35
ORA-06512: 在 "SYS.DBMS_OUTPUT", line 115
ORA-06512: 在 line 7

 


参见下法解决(摘自《Oracle Database 10g完全参考手册》第47章):《《《《《《
《《《《《《《《

You can access XSU via Java and PL/SQL APIs (application programming 
interfaces). The XSU
Java classes are part of the Oracle kernel software. The PL/SQL API is a 
wrapper that publishes
the Java classes to PL/SQL (see Chapter 39). Because the XSU classes are 
stored in the database,
you can write new stored procedures to directly access XSU’s Java classes. 
Because a PL/SQL
API is available, XSU’s functionality can be accessed directly through 
SQL.
For example, you can generate the XML version of the RATING table via the 
XSU PL/SQL
procedures. The following listing creates a procedure named PRINTCLOBOUT 
that will be called
as part of the data-output process. The data will be read in as a CLOB.


create or replace procedure PRINTCLOBOUT(result IN OUT NOCOPY CLOB)
is
xmlstr varchar2(32767);
line varchar2(2000);
begin
xmlstr := dbms_lob.SUBSTR(result,32767);
loop
exit when xmlstr is null;
line := substr(xmlstr,1,instr(xmlstr,chr(10))-1);
dbms_output.put_line('| '||line);
xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
end loop;
end;
/


Now that the PRINTCLOBOUT procedure exists, run the following anonymous 
PL/SQL block.
This block queries the RATING table, so that table must be accessible from 
your schema (see the
accompanying CD-ROM).
NOTE
You must set serveroutput on prior to executing this PL/SQL block.

 

declare
queryCtx DBMS_XMLquery.ctxType;
result CLOB;
begin
-- set up the query context...
queryCtx := DBMS_XMLQuery.newContext('select * from rating');
-- get the result..
result := DBMS_XMLQuery.getXML(queryCtx);
-- Now you can use the result to put it in tables/send as messages..
printClobOut(result);
DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query..
end;
/

》》》》》》》》》》》》》》》》》

 

 

 

注:在存储过程中使用存储过程时,则不需要加“exec”。。。如:printClobOut(result);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值