日期:2014-05-17  浏览次数:21204 次

存储过程报ORA-01722无效数字错误
create or replace procedure p_fp_pjzxkchz(as_fpDjxh in varchar2,
  as_swjgDm in varchar2,
  as_ckDm in varchar2,
  as_swryDm in varchar2) is
  /*
  存储过程说明:此存储过程用于对通过"回调"或"删除调拨单"进入票据中心库存的同类票(入库单价相同)进行汇总合并*/
  ls_fpzlDm t_fp_fpdjmx.fpzl_dm%type;
  ls_fpDm t_fp_fpdjmx.fp_dm%type;
  ls_fpQshm t_fp_fpdjmx.fp_qshm%type;
  ls_fpZzhm t_fp_fpdjmx.fp_zzhm%type;
  ls_sldwDm t_fp_fpdjmx.sldw_dm%type;
  ls_sl t_fp_fpdjmx.sl%type;
  ls_sl1 t_fp_fpdjmx.sl%type;
  ls_sl2 t_fp_fpdjmx.sl%type;
  ls_dj1 t_fp_fpdjmx.dj%type;
  ls_dj2 t_fp_fpdjmx.dj%type;
  ls_dj t_fp_fpdjmx.dj%type;
  qshm t_fp_fpdjmx.fp_qshm%type;
  zzhm t_fp_fpdjmx.fp_zzhm%type;
  cursor c_fpdjmx is
  select * from t_fp_fpdjmx t where t.fpdj_xh = as_fpDjxh;
begin
  --循环刚入库的票
  for cur in c_fpdjmx loop
  ls_fpzlDm := cur.fpzl_dm;
  ls_fpDm := cur.fp_dm;
  ls_fpQshm := cur.fp_qshm;
  ls_fpZzhm := cur.fp_zzhm;
  ls_sldwDm := cur.sldw_dm;
  ls_sl := cur.sl;
  --1查找库存中是否有与该号码相连的票,并将其合并
  --1.1先找与该起始号码相连的
  select sum(kc.sl)
  into ls_sl1
  from t_fp_swjgfpkc kc
  where kc.swjg_dm = as_swjgDm
  and kc.ck_dm = as_ckDm
  and kc.swry_dm = as_swryDm
  and kc.fpzl_dm = ls_fpzlDm
  and kc.fp_dm = ls_fpDm
  and kc.fp_zzhm = ls_fpQshm - 1
  and kc.sldw_dm = ls_sldwDm;
  --1.2找与该终止号码相连的
  select sum(kc.sl)
  into ls_sl2
  from t_fp_swjgfpkc kc
  where kc.swjg_dm = as_swjgDm
  and kc.ck_dm = as_ckDm
  and kc.swry_dm = as_swryDm
  and kc.fpzl_dm = ls_fpzlDm
  and kc.fp_dm = ls_fpDm
  and kc.fp_qshm = ls_fpZzhm + 1
  and kc.sldw_dm = ls_sldwDm;
  --2分三段分别找出其入库价格

  select nvl(djmx.dj, 0)
  into ls_dj1
  from t_fp_fprkd rkd, t_fp_fpdjmx djmx
  where rkd.jsdw_dm = as_swjgDm
  and rkd.jsck_dm = as_ckDm
  and rkd.fprkd_xh = djmx.fpdj_xh
  and djmx.fpdj_lx = '0'
  and djmx.fpzl_dm = ls_fpzlDm
  and djmx.fp_dm = ls_fpDm
  and djmx.fp_qshm <= qshm
  and djmx.fp_zzhm >= ls_fpQshm - 1;

指到这一行错误。

------解决方案--------------------
不知道...
隐式转换中出错的吧
最好保持数据类型的一致
比如这句可以改为djmx.fp_zzhm>=to_char(to_number(ls_fpqshm)-1)