create or replace procedure dqzj_dfxx(ac_ny in varchar2,ac_qf in varchar2) is
  n_abc number;
  str varchar2(200);
begin
  str:='insert into n_abc select :1 from qfb1 where ny=:2';
  execute immediate str using ac_qf,ac_ny;
end;

解决方案 »

  1.   

    create or replace procedure dqzj_dfxx(ac_ny in varchar2,ac_qf in varchar2) is
      n_abc number;
      str varchar2(200);
    begin
    str:='insert into n_abc select'||ac_ny ||' from  qfb1 where ny='||ac_qf ;
    execute immediate str;
    end;
      

  2.   

    str中要写一个常量,怎么写呢?str:='insert  into  table1(a,b,c) select 'a','b','c' from dual,为什么不执行
      

  3.   

    str:='insert  into  table1(a,b,c) select ''a'',''b'',''c'' from dual';
      

  4.   

    为什么这句不能执行呢,应该怎么写
    execute immediate 'update jczj_c_dfxx a set ysdf= (select qf10 from dq.dfsqf b where a.hh=b.hh)' ;
      

  5.   

    我这样写了为什么更新不了啊
    create or replace procedure dqzj_dfxx(
    ac_qfny in varchar2
    }is
    begin
    execute immediate 'update jczj_c_dfxx a set ysdf= (select '||ac_qfny||'  from dq.dfsqf b where a.hh=b.hh)' ;
    end;
      

  6.   

    你先执行update jczj_c_dfxx a set ysdf= (select '||ac_qfny||'  from dq.dfsqf b where a.hh=b.hh)有没有更新.
      

  7.   

    这样可以成功执行啊
    declare
    ac_qfny varchar2(10):='qf10';
    beginupdate jczj_c_dfxx a set ysdf= (select '||ac_qfny||'  from dq.dfsqf b where a.hh=b.hh);end;
    /
      

  8.   

    哦,我发现了,上面那个不能执行的,因为qf10中可能有空值,所以不让改,那再请教一句怎么把空值赋成0,这样我试了不行
    update jczj_c_dfxx a set ysdf= (select '||nvl(ac_qfny,0)||'  from dq.dfsqf b where a.hh=b.hh);
      

  9.   

    还没有彻底解决呀,那位再看一下哦,我这样为什么不更新,写法有问题吗
    declare  
    ac_qfny  varchar2(10):='qf10';  
    ac_dw  varchar2(4):='C1'
    begin  
     
    execute  immediate  'update  jczj_c_dfxx  a  set  ysdf=  (select  '||ac_qfny ||'
      from  dq.dfsqf  b  where  a.hh=b.hh) where dw='||ac_dw;  
     
    end;  /