大侠们,来看看,这样的处理会出问题的,我该怎么做,请给一个详细的解答,最好是有一个小例子(100分)

  • 主题发起人 主题发起人 xlgtyx
  • 开始时间 开始时间
X

xlgtyx

Unregistered / Unconfirmed
GUEST, unregistred user!
dm_ljsjk.DB_YYGL.StartTransaction;<br> &nbsp; &nbsp; &nbsp; &nbsp;//将原单据中的药品删除并修改当前药品的可库存量<br> &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.Close;<br> &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.SQL.Clear;<br> &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.SQL.ADD('SELECT YJ_DJMX_LS,YJ_DJ_DM,YJ_DJMX_YPPC,B_YP_LS,YJ_DJMX_ZBBM,YJ_DJMX_LSSL FROM YJ_DJMX WHERE B_YPXX_YPDM='''+QRY_YJDJMX.FIELDBYNAME('B_YPXX_YPDM').AsString+'''');<br> &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.SQL.ADD(' AND YJ_DJ_DM='''+QRY_YJDJMX.FIELDBYNAME('YJ_DJ_DM').AsString+'''');<br> &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.Open;<br> &nbsp; &nbsp; &nbsp; &nbsp;WHILE NOT QRY_CX.Eof DO<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BEGIN<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.Close;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.SQL.Clear;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.SQL.Add('UPDATE YJ_KCTZ SET YJ_KCTZ_KYSL=YJ_KCTZ_KYSL+:A1 ');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.SQL.Add(' WHERE YJ_KCTZ.YJ_KCTZ_ZBBM=:A2 AND YJ_KCTZ.B_YP_LS=:A3 AND ');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.SQL.Add(' YJ_KCTZ.YJ_KCTZ_YPPC=:A4 '); &nbsp; &nbsp;// AND YJ_DJ_DM=:A5<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.Params[0].AsFloat:=QRY_CX.FIELDBYNAME('YJ_DJMX_LSSL').AsFloat;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.Params[1].AsString:=QRY_CX.FIELDBYNAME('YJ_DJMX_ZBBM').AsString;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.Params[2].AsInteger:=QRY_CX.FIELDBYNAME('B_YP_LS').AsInteger;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.Params[3].AsInteger:=QRY_CX.FIELDBYNAME('YJ_DJMX_YPPC').AsInteger;<br> &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.Params[4].AsString:=QRY_CX.FIELDBYNAME('YJ_DJ_DM').AsString;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_TJ.ExecSQL;<br><br><br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.Next;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END;<br> &nbsp; &nbsp; &nbsp; &nbsp; QRY_CX.Close;<br> &nbsp;// &nbsp; &nbsp; 程序在运行到下面的代码时出现死锁<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.Close;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.SQL.Clear;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.SQL.Add('SELECT YJ_KCTZ_KCSL FROM YJ_KCTZ WHERE YJ_KCTZ_LS=:A1');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.Params[0].AsInteger:=QRY_YJKC.FIELDBYNAME('YJ_KCTZ_LS').AsInteger;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QRY_CX.Open;//程序在运行到下面的代码时出现死锁<br><br>后面有提交<br><br>象这样如果对一个事务的开始<br>dm_ljsjk.DB_YYGL.StartTransaction;<br> &nbsp;在这中间首先从一个表中读出数据集,或是修改一部分数据集,之后双在后面的程序代码中做修改数据或读数据,这样就会出现死锁,如何解决这样的问题,或是大家给我一个解决的方案.<br>dm_ljsjk.DB_YYGL.Commit;
 
后退
顶部