我在一个存储过程中加入如下语句有问题!请高手指导!小弟才加入的新人没有分给对不住各位大侠!原理如下!
有两个系统表aaa,spph,一个临时表#djmx;其中spph,aaa,#djmx字段分别为id,ph,hw,shq,sl,pqf,kxwd
临时表#djmx的值取之制单表aaa中@bs=116的值!而spph的值取之临时表#djmx的值!pqf,kxwd是系统表中后来增加的两个字段。因为工程浩大
这两个字段的取值必须是在#djmx中(pqf,kxwd).整个过程不可逆反!
现在我遇到的难题是倒手第一个IF语句!不能被执行也没有报错信息!已经确定每个表里都有值!!!!!
以下是截取一段存储过程!前提整个存储过程只有这段执行不完全!其他都没有问题?create table #djmx (
  
  id char(11) null default '',
  ph char(10) null default '',
  hw char(11) null default '',
  shq char(10) null default '',
  sl decimal(14,2) null default 0,
  pqf char(30) null default '',
  kxwd char(11) null default ''
)
if @bs='116'
  begin
--制单116(流程)
    insert into #djmx (id,ph,hw,shq,sl,pqf,kxwd)
      select 
           id,isnull(ph,''),hw,isnull(shq,''),sl,isnull(pqf,''),isnull(kxwd,'')
      from aaa (nolock) ------aaa临时表
      where gz=@gz and xz=1
  endif @bs='116' --更新spph中的pqf,kxwd的值
begin
 if (select count(*) from #djmx where pqf<>'' and kxwd<>'' )>0
begin
  update a set a.pqf=b.pqf,a.kxwd=b.kxwd  from spph a,#djmx b where a.id=b.id and a.hw=b.hw and a.ph=b.ph and a.sl=b.sl
end
    if @@error <> 0 
    begin
set @return=11
goto err_lab
    end 
end
drop table #djmx