zoukankan      html  css  js  c++  java
  • oracle ORA-01704: string literal too long

    导出数据时,在SQL拼接处,提示 oracle ORA-01704: string literal too long

     sql:

     WITH already_in AS
     (SELECT distinct REGEXP_SUBSTR('-999,CX201702210003,CX201702270003,……,CX201702270004', '[^,]+', 1, level) col   from dual
      connect by level <= length(regexp_replace(''-999,CX201702210003,CX201702270003,……,CX201702270004',  '[^,]*')) + 1)
    select pro.*, u.user_name PROJECT_MANAGER_NAME
      from cp_p pro  left join cdc_u u    on u.user_id = pro.PROJECT_MANAGER
     where 1 = 1   and exists (select * from already_in al where al.col = pro.project_code)
       AND pro.project_manager not in (select info.user_id  from cdc_user_info info  where info.user_name in ('fff'))
     
    拼接的字符串超长导致“string” 抛异常。减少了拼接字符后,顺利执行。
    注意:在拼接sql时,用于某类型字段的拼接,需要注意其长度。事先预测一下需要拼接的字符最长会达到多少,超长的话可以使用clob类型字段。
    尽量避免拼接超长字符用在sql中,如必须,可以声明一个事务变量,或者分页处理(或分段连接处理)。
     
    网上有相关处理方式,引用一下:

    有两种方法可以解决:

    1.使用存储过程,把超长文本保存在一个变量中,然后再insert update

    declare
    v_clob clob :='一个长文本';
    begin
      insert into table values(a,3,:clob);
     end;

    2.字符串拼接,update使用字符串拼接

     update mall_config set category_info='安全防护:3003,' where id=1;

    update mall_config set category_info=category_info||'|标准件:1040140,1035382,' where id=1;

  • 相关阅读:
    swift函数
    Swift数据类型
    swift的特点
    图片适配、九宫切图
    iOS中视图控制器的生命周期
    CocoaPods的安装与使用
    SQLite3的使用
    Pickers应用程序
    多视图应用
    OC对象的三大特性:封装、继承和 多态
  • 原文地址:https://www.cnblogs.com/yeyuchangfeng/p/6677040.html
Copyright © 2011-2022 走看看