IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_166_dolinkdata_2774]') AND type = 'P')
DROP PROCEDURE [dbo].[order_166_dolinkdata_2774]
GO
create procedure order_166_dolinkdata_2774(
@cmpid int ,
@useruid int ,
@bizid int ,
@ordbcid int,
@ordid bigint,
@jbid bigint,
@ftype varchar(10),
@fbizid int,
@fordid bigint,
@ford2tag int ,
@ford2id bigint,
@rtype varchar(10),
@rbizid int,
@rordid bigint,
@rord2tag int ,
@rord2id bigint 
) 
as 
begin
declare @operation varchar(50) 
declare @errorinfo nvarchar(4000)  
declare @newobjid bigint 
declare @ident varchar(40) 
declare @newsql nvarchar(max) 
declare @condition nvarchar(4000) 
declare @authority varchar(200) 
declare @bcid int 
set @bcid=@ordbcid 



set @operation = 'continue' 
set @errorinfo='' 
set @newobjid = 0 
set @ident=convert(varchar(100),convert(decimal(18,11),CURRENT_TIMESTAMP)) 
set @newsql = '' 
set @authority = '' 
set @condition = '' 
-- 以下是用户扩展的程序  ---- 

-- 以上是用户扩展的程序  ---- 
if (@operation = 'continue') 
begin 

set @newsql='

update old2 set  old2.ord2_updated=getdate() ,  old2.ord2_ysje=old2.ord2_ysje+new2.ord2_bcsk
from order_166 new , order_166_1 new2 ,order_171 old , order_171_1 old2 
where  new.ord_id=@ordid and new2.ord2_ordid=@ordid 
 and old2.ord2_id=new2.ord2_ford2id and old2.ord2_ordid=old.ord_id
'
if (@condition>'') set @newsql=@newsql+' and ('+@condition+') ' 

exec sp_executesql @newsql, N'@cmpid int,@useruid int,@bizid int,@ordbcid int,@ordid bigint,@jbid bigint,@ftype varchar(10),@fbizid int,@fordid bigint,@ford2tag int ,@ford2id bigint,@rtype varchar(10),@rbizid int,@rordid bigint,@rord2tag int ,@rord2id bigint,@newobjid bigint,@ident varchar(40),@authority varchar(300),@bcid int ', @cmpid,@useruid,@bizid,@ordbcid,@ordid,@jbid,@ftype,@fbizid,@fordid,@ford2tag,@ford2id,@rtype,@rbizid,@rordid,@rord2tag,@rord2id,@newobjid,@ident,@authority,@bcid 
end 

--- 下面这段程序，是完成帐务处理------

--- 帐务处理完毕 ------

end