for n in A1 loop
    m_cnt := 0;
    m_val := 0;
  s_sql:='select  count(*),sum(a.duration) from 
ocsbill.ocs_event_tgcdr_9010'||month1||
          '@billdb a,ocsbill.ocs_event_tgcdr_fee_9010'||month1||'@billdb b
where a.event_inst_id= b.event_inst_id and calling_visit_region=''0790'' and
a.calling_nbr='||n.dn_no||' and a.billing_nbr='||n.dn_no||' group by a.billing_nbr';
     execute immediate s_sql      into m_cnt, m_val;
    update lydate
       set bjbd_val = m_val, bjbd_cnt = m_cnt
     where dn_no = n.dn_no;
    commit;
  end loop;
--以上是我程序脚本的一部分,运行提示错误,提示这一行execute immediate s_sql
invalid number! 可是我以前都可以运行,现在却不行了。谁帮我看看是哪里的问题吗?

解决方案 »

  1.   

    n.dn_no 是什么类型的
    s_sql:='select count(*),sum(a.duration) from  ocsbill.ocs_event_tgcdr_9010'||month1||
      '@billdb a,ocsbill.ocs_event_tgcdr_fee_9010'||month1||'@billdb b
    where a.event_inst_id= b.event_inst_id and calling_visit_region=''0790'' and
    a.calling_nbr='||n.dn_no||' and a.billing_nbr='''||n.dn_no||''' group by a.billing_nbr';
      execute immediate s_sql into m_cnt,m_val;
      

  2.   

    s_sql:='select count(*),sum(a.duration) from  ocsbill.ocs_event_tgcdr_9010'||month1||
      '@billdb a,ocsbill.ocs_event_tgcdr_fee_9010'||month1||'@billdb b
    where a.event_inst_id= b.event_inst_id and calling_visit_region=''0790'' and
    a.calling_nbr='||n.dn_no||' and a.billing_nbr='''||n.dn_no||''' group by a.billing_nbr';
      execute immediate s_sql into m_cnt,m_val;
      

  3.   

    s_sql:='select count(*),sum(a.duration) from ocsbill.ocs_event_tgcdr_9010'||month1||
      '@billdb a,ocsbill.ocs_event_tgcdr_fee_9010'||month1||'@billdb b
    where a.event_inst_id= b.event_inst_id and calling_visit_region=''0790'' and
    a.calling_nbr='''||n.dn_no||''' and a.billing_nbr='''||n.dn_no||''' group by a.billing_nbr';
      execute immediate s_sql into m_cnt,m_val;
      

  4.   

    应该不是这里的问题吧,因为我程序其他地方也有这样的语句,比如
    s_sql:='select  count(*),sum(a.duration) from 
    ocsbill.ocs_event_tgcdr_9010'||month1||
              '@billdb a,ocsbill.ocs_event_tgcdr_fee_9010'||month1||'@billdb b
    where a.event_inst_id= b.event_inst_id and ( a.calling_belong_region<>''0790'' or called_visit_region<>''0790'')
    and a.called_nbr='||n.dn_no||' and a.billing_nbr='||n.dn_no||' group by a.billing_nbr';  这里就没报错
      

  5.   

    建议你把 sql 打印出来看看。
      

  6.   

    打印出来后,在sql中调试一下
      

  7.   

    s_sql:='select count(*),sum(a.duration) from ocsbill.ocs_event_tgcdr_9010'||month1||
      '@billdb a,ocsbill.ocs_event_tgcdr_fee_9010'||month1||'@billdb b
    where a.event_inst_id= b.event_inst_id and calling_visit_region=''0790'' and
    a.calling_nbr='||n.dn_no||' and a.billing_nbr='''||n.dn_no||''' group by a.billing_nbr';
      execute immediate s_sql into m_cnt,m_val;
    你说你的n.dn_no 是字符型的肯定的'''||n.dn_no||'''这样拼接没数据不好测
    那就先输出看看
    dbms_output.put_line(s_sql); 
    先别执行execute immediate s_sql
      

  8.   

    用pl/sql工具debug调试一下,看看到底是哪出了问题!这样针对性比较强,比较容易找出问题所在!
      

  9.   

    我知道哪里的问题了。where a.event_inst_id= b.event_inst_id and calling_visit_region=''0790'' and
    a.calling_nbr='||n.dn_no||' --这里 calling_nbr 加了to_char 转换了下,就没报错了。