我想用存储过程把另一个数据库中的package,存储过程等拿到当前数据库中创建。通过user_source得到了全部代码,想用EXECUTE IMMEDIATE 动态循环生成,代码小于32k时,没有问题;大于32k有ora-06502字符串缓冲区太小错误,请问该怎样做?

解决方案 »

  1.   

    怎么分段呢 ?EXECUTE IMMEDIATE strSQL ,strSQL是一个包的整个创建语句,并不是可以分开的简单sql呀
      

  2.   

    declare
    v_sql varchar2(xxxx);
    begin
    ...
    EXECUTE IMMEDIATE v_sql;
    end;
    /
    把这个存放动态SQL的变量v_sql设大些。
      

  3.   

    楼上,都32k了,varchar2才4000呀,我用long呢
      

  4.   

    我曾经试图做成sql文件,但EXECUTE IMMEDIATE '@c:\file.sql'也是不能通过的
      

  5.   

    我搜了下,怎么这个错误提示好像不是说缓冲区太小:
    ORA-06502: PL/SQL: numeric or value error string 
    Cause: An arithmetic, numeric, string, conversion, or constraint error occurred. For example, this error occurs if an attempt is made to assign the value NULL to a variable declared NOT NULL, or if an attempt is made to assign an integer larger than 99 to a variable declared NUMBER(2). 
    Action: Change the data, how it is manipulated, or how it is declared so that values do not violate constraints.