create procedure dbo.%PROC% @sid varchar(30) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @new_state_id numeric, @type_id numeric select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER .CHECK_UPDATE .GET_PROPS declare @rep_id numeric declare @prev_id numeric declare @arch_date datetime begin tran .EXEC_ACTION (@sid, 'PARTJUR_CHANGE', 'CANCELLATION_CHANGES', 1) .UPDATE_STATE .ACTION_HISTORY if (@class_id !=1) begin .MAIN_MOVE(L,'CRT',YES) end else begin .MAIN_MOVE(L,'BLK',YES) end delete t_items from td_depo_docs, t_types where t_items.id=td_depo_docs.id and td_depo_docs.foundation_id=@id and t_items.type_id=t_types.id and upper(t_types.type_code) in ('REPORT4REFUS_OPER', 'REPORTS_REPORT_FOR_CHANGEJUR') delete td_depo_docs where td_depo_docs.foundation_id=@id and not exists(select 1 from t_items where id=td_depo_docs.id) .ARH_FLAG_CLEAR -- kashuba_av begin Закоментарил, так как это спецреговское и нам мешает --.SR_REG_JOURNAL_DEL(@id) --.SR_REPORTS_DESTROY(@id) -- kashuba_av end commit tran