存储过程如下
插入哦前10个人都正常,到插入第11人的时候patientno的值还是10,之后插入的就一直都是10了
什么情况大家帮我看看,我看了两个小时了也没看出来哪里有问题
- SQL code
CREATE OR REPLACE Procedure p_b_insertmz(scardno Varchar2,scheckno Varchar2,scheckname varchar2,shiscardno Varchar2,spatientname Varchar2,spatientsex Varchar2,spatientage Varchar2, spatientid varchar2, sVoucherNo Varchar2,sfreetype Varchar2,sregistope Varchar2,drgistdate Date, ipatientautoid Out Number )--将门诊病人加入排队Is maxorderi Number; maxno Number; icout Number; chkflag varchar2(2);Begin Select nvl(max(patientorder)+5,5 ) Into maxorderi From t_b_patient Where to_char(patienttime,'yyyymmdd')=to_char(Sysdate,'yyyymmdd'); Select nvl(Max(patientno)+1,1) Into maxno From t_b_patient Where to_char(patienttime,'yyyymmdd')=to_char(Sysdate,'yyyymmdd') And checkno=scheckno ; Select Count(*) Into icout from t_b_checkkind Where checkno=scheckno; chkflag:='A'; If icout>0 Then Select nvl(checkflg,'A') Into chkflag from t_b_checkkind Where checkno=scheckno; End If; Select s_b_patient.nextval Into ipatientautoid From dual; Insert Into t_b_patient(autoid,cardno,hiscardno,patientid,patientno,patientname,patientsex,patientage,registtime,feetype,voucherno,rigistdate, registope, ispre,isinvalid,checkname,patientstatus,patienttime,patientprior,patientorder,checkno,checkflag) Values(ipatientautoid,scardno,shiscardno,spatientid,maxno,spatientname,spatientsex,spatientage,sysdate,sfreetype,svoucherno,drgistdate, sregistope,0,0,scheckname,1,sysdate,'D-普通',maxorderi,scheckno,chkflag);Commit;End p_b_insertmz;
------解决方案--------------------
autoid 这个字段有增加么?
------解决方案--------------------
Select nvl(Max(patientno)+1,1) From t_b_patient Where to_char(patienttime,'yyyymmdd')=to_char(Sysdate,'yyyymmdd') And checkno=scheckno ;
你插入 11 条数据以后,你看下这个返回多少
------解决方案--------------------
checkno 你不会这个字段变了吧
从代码看,应该是没问题的