DELETE 
FROM AKUZ.T_RDS_SYNCHRONIZATION_CONFIG 
WHERE MessageType LIKE '%DLO%'
GO

INSERT INTO AKUZ.T_RDS_SYNCHRONIZATION_CONFIG (
    Entities,
    ProcessName,
    MessageType,
    LockResourcePath,
    LockGroupName,
    ProcessType,
    Operations,
    IgnoreNullResource,
    RdsQueue,
    RdsSynchronizationConfigID,
    PathToImportServer
)
VALUES 
(
    (SELECT TOP 1 EntityId FROM VCLib.T_ENTITIES e WHERE e.EntName = 'DLO_ACCESSED_POSTS'),
    'AKUZ.sp_AKUZ_FTLOAD_DloAccessPost',
    'DLO_ACCESSED_POSTS',
    NULL,
    NULL,
    0,
    31,
    0,
    NULL,
    NEWID(),
    NULL
),
(
    (SELECT TOP 1 EntityId FROM VCLib.T_ENTITIES e WHERE e.EntName = 'DLO_ACCESSED_POSTS_DIRECTION'),
    'AKUZ.sp_AKUZ_DloAccessPostDirection',
    'DLO_ACCESSED_POSTS_DIRECTION',
    NULL,
    NULL,
    0,
    31,
    0,
    NULL,
    NEWID(),
    NULL
)
GO

DELETE FROM VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM 
WHERE ObjectModificationAction IN (
	SELECT ObjectModificationActionID
	FROM VCLib.T_OBJECT_MODIFICATION_ACTION a1
	WHERE a1.name LIKE '%sp_RDS_DirectionForDloAccessXml%')
GO

DELETE FROM VCLib.T_SINGLE_MODIFICATION_ACTION 
WHERE ObjectModificationActionID in (
	SELECT ObjectModificationActionID
	FROM VCLib.T_OBJECT_MODIFICATION_ACTION a1
	--WHERE a1.name LIKE '%DLO%')
	WHERE a1.name LIKE '%sp_RDS_DirectionForDloAccessXml%')
GO

DELETE FROM VCLib.T_OBJECT_MODIFICATION_ACTION 
WHERE name LIKE '%sp_RDS_DirectionForDloAccessXml%'
--WHERE name LIKE '%DLO%'
GO

declare @newid uniqueidentifier
set @newid = NEWID()

INSERT INTO VCLib.T_OBJECT_MODIFICATION_ACTION 
(	
	ObjectModificationActionID,
	Entities,
	Position,
	type_,
	active,
	Name,
	Instruction,
	InstructionType
)
VALUES
(
	@newid,
	(SELECT TOP 1 EntityId FROM VCLib.T_ENTITIES e WHERE e.EntName = 'DLO_ACCESSED_POSTS_DIRECTION'),
	1,
	(SELECT TOP 1 EntityId FROM VCLib.T_ENTITIES e WHERE e.EntName = 'SINGLE_MODIFICATION_ACTION'),
	1,
	'AKUZ.sp_AKUZ_DloAccessPostDirection',
	'AKUZ.sp_AKUZ_DloAccessPostDirection',
	0
)

INSERT INTO VCLib.T_SINGLE_MODIFICATION_ACTION
(
	ObjectModificationActionID,
	InsertFilter,
	UpdateFilter,
	DeleteFilter,
	EditType
)
VALUES
(
	@newid,
	NULL,
	NULL,
	NULL,
	14
);

INSERT INTO VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM
(
	ObjectModificationActionParamID,
	ObjectModificationAction,
	ParamValue,
	Name
)
VALUES
(
	NEWID(),
	@newid,
	'<lx:ConstOperand type="String" xmlns:lx="lexem"><![CDATA[rds.registry]]></lx:ConstOperand>',
	'@QueueName'
),
(
	NEWID(),
	@newid,
	'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">      <lx:StepString name="DloAccessedPostsDirectionID" />  </lx:Path>',
	'@ID'
)
GO