zoukankan      html  css  js  c++  java
  • ORA-01489: result of string concatenation is too long

    ORA-01489: result of string concatenation is too long
    Cause: String concatenation result is more than the maximum size.
    Action: Make sure that the result is less than the maximum size.
    
    Reference: 
    http://nimishgarg.blogspot.com/2012/06/ora-01489-result-of-string.html
    http://docs.oracle.com/cd/B19306_01/server.102/b14219/e900.htm
    
    
    Example:
    SQL> SELECT LPAD('x',4000,'x') || LPAD('x',4000,'x')  || LPAD('x',4000,'x') FROM DUAL;
    SELECT LPAD('x',4000,'x') || LPAD('x',4000,'x')  || LPAD('x',4000,'x') FROM DUAL
                                                                                                       *
    ERROR at line 1:
    ORA-01489: result of string concatenation is too long
    
    
    Problem Description:
    The problem with this query is with the use of CONCAT operator (||).
    
    e.g.: select char1 || char2 from dual
    Concat operator returns char1 concatenated with char2. The string returned is in the 
    same character set as char1. So here concat operator is trying to return varchar2, 
    which has limit of 4000 characters and getting exceeded.
    
    This problem may also come when we try to CONCAT a VARCHAR2 with CLOB.
    e.g.: select char1 || clob from dual
    
    So here we can simply convert its first string to CLOB and avoid this error.
    After converting first string to CLOB, CONCAT operator will return string of CLOB type
    
    
    Solution:
    SELECT TO_CLOB(LPAD('x',4000,'x')) || LPAD('x',4000,'x')  || LPAD('x',4000,'x') 
    FROM DUAL
  • 相关阅读:
    自我介绍
    秋季学期总结
    第七周编程总结
    第六周作业
    第五周编程总结
    第四周编程总结
    第三周作业
    第二周作业
    抓老鼠啊~亏了还是赚了
    币值转换
  • 原文地址:https://www.cnblogs.com/ShineTan/p/3298645.html
Copyright © 2011-2022 走看看