Oracle Sql Developer“字符串文字太长”错误

前端之家收集整理的这篇文章主要介绍了Oracle Sql Developer“字符串文字太长”错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在Oracle sql Developer中针对Oracle 10g服务器运行以下sql
  1. WITH openedXml AS (
  2. SELECT extractvalue(column_value,'/theRow/First') FIRST,extractvalue(column_value,'/theRow/Last') LAST,to_number(extractvalue(column_value,'/theRow/Age')) Age
  3. FROM TABLE(XMLSequence(XMLTYPE('
  4. <theRange>
  5. <theRow><First>Bob</First><Last>Smith</Last><Age>30</Age></theRow>
  6. <theRow><First>Sue</First><Last>Jones</Last><Age>34</Age></theRow>
  7. ...
  8. ...
  9. ...
  10. <theRow><First>Tom</First><Last>Anderson</Last><Age>39</Age></theRow>
  11. <theRow><First>Ali</First><Last>Grady</Last><Age>45</Age></theRow>
  12. </theRange>
  13. ').extract('/theRange/theRow')))
  14. )
  15. SELECT *
  16. FROM openedxml
  17. WHERE age BETWEEN 30 AND 35;

当我尝试运行它时,我收到以下错误

  1. Error at Command Line:1 Column:0 Error report: sql Error: ORA-01704: string literal too long
  2. 01704. 00000 - "string literal too long"
  3. *Cause: The string literal is longer than 4000 characters.
  4. *Action: Use a string literal of at most 4000 characters.
  5. Longer values may only be entered using bind variables.

我的字符串偶尔会超过4000个字符.关于如何解决这个问题的任何想法?

您将需要使用CLOB作为XMLTYPE()的输入而不是VARCHAR.

使用dbms_lob.loadclobfromfile从文件加载xml,或者将xml拆分为32000个字符块并附加到CLOB.

  1. DECLARE
  2. xmlClob CLOB;
  3. BEGIN
  4. /* Build Clob here */
  5.  
  6. WITH openedXml AS (
  7. SELECT extractvalue(column_value,'/theRow/Age')) Age
  8. FROM TABLE(XMLSequence(XMLTYPE(xmlClob).extract('/theRange/theRow')))
  9. )
  10. SELECT *
  11. FROM openedxml
  12. WHERE age BETWEEN 30 AND 35;
  13. END;

猜你在找的Oracle相关文章