hur.cn - 华软网

 热门搜索

关于PB调用存储过程锁表的问题,急,在线等

  作者:未知    来源:网络    更新时间:2018/10/12
存储进程以下:
-----------------------------------------------------
/*根据扫出货串号自动生成调整单*/
CREATE    PROCEDURE  sp_createadjust  @outstoreno int,@outstoredate datetime ,@senderid varchar(10)

AS
  declare @productid_sn varchar(10),
          @colorname_sn varchar(10),
          @amount_sn int,
          @amount_detail int,
          @adjustno int,
          @outdeptid int,
          @outstoreadjustno int,
         @message varchar(1000) 

      declare cur_outstoresn  cursor --设置游标 串号表跟明细表对比,按编号、颜色分组如果串号数目>明细表数目 则 调整单数目 =明细表数目-串号数目
       for 
select  productid,colorname ,count(productsn) from outstoresn where outstoreno=@outstoreno
             group by productid,colorname
           open cur_outstoresn
fetch next from cur_outstoresn into @productid_sn,@colorname_sn,@amount_sn
   while(@@fetch_status = 0)
    begin --1
                    set @amount_detail=0
                   set @adjustno=0
                     select @amount_detail=outstoreamount from outstoredetail where productid=@productid_sn and 
                             colorname=@colorname_sn and outstoreno=@outstoreno
                    if @amount_sn>@amount_detail
                      begin
                        select @adjustno=outstoreno from outstore where adjustno=@outstoreno
                        if @adjustno=0
                          begin 
                           insert into outstore(outdeptid,indeptid,outstoredate,senderid,inouttype,adjustno) values
                            (@outdeptid,74,@outstoredate,@senderid,8,@outstoreno)
                            select @adjustno=max(outstoreno) from outstore 
                                         set  @outstoreadjustno=  @adjustno            
                          end
                         insert into outstoredetail(outstoreno,productid,colorname,outstoreamount) values
                            (@adjustno,@productid_sn,@colorname_sn, @amount_detail - @amount_sn ) 
                    
                         
                     end 
                 fetch next from cur_outstoresn into @productid_sn,@colorname_sn,@amount_sn
              end  --1
       close cur_outstoresn
     deallocate cur_outstoresn
  
        

  if @outstoreadjustno> 0  
       set  @message='您所扫的串号型号、颜色或数目与出货明细不一致,系统生成对应的调整单,单号为: ' + 
         cast(@outstoreadjustno as varchar) + '   ,是否打开该调整单?'  

   select @message
GO
-------------------------------------------------------
其中执行了一些表的插入和更新操作

PB调用该存储进程
-------------------------------------------------------

DECLARE sp_createadjust PROCEDURE FOR sp_createadjust 
@outstoreno = :ls_no,
@outstoredate = :ld_date,
@senderid = :gs_userid;

 EXECUTE sp_createadjust ;
 fetch sp_createadjust into  :ls_message;
if sqlca.sqlcode<>0 then

close  sp_createadjust;
return
else

if messagebox("提醒",ls_message,Question!,YesNo!,2)=1 then
end if
end if
close  sp_createadjust; 
-------------------------------------------------------
在程序里面执行该存储进程,我在查询分析器查询插入的表就锁表了,请问怎样释放程序调用存储进程呢?谢谢!!!

------华软网友回答------
执行完SP后,执行COMMIT语句
------华软网友回复------
在程序加了COMMIT照旧一样啊,锁S了,只有关了程序才在查询分析器显示数据

------华软网友回复------
顶啊,高手帮助啊,谢了
------华软网友回复------
你怎么加commit的,贴出代码来看看
------华软网友回复------
在存储进程中加commit



qfkx.com      
华软声明:本内容来自网络,如有侵犯您版权请来信指出,本站立即删除。