x
1
BEGIN
2
DECLARE _existingRoleId INT(11);
3
4
SET _existingRoleId = (SELECT RoleDefinitionId FROM RoleDefinitions WHERE RoleDetectionGuid = argRoleDetectionGuid);
5
6
if ISNULL(_existingRoleId) THEN
7
INSERT INTO `RoleDefinitions` (`RoleName`, `RoleType`, `RoleSubType`, `DetectionString`, `ComparisonOperator`, `ComparisonResult`, `SerialKeyString`, `ProductKeyString`, `RoleDetectionGuid`, `IsRemote`, `SearchId`, `IsSupport`, `ParentRoleDefinitionGuid`)
8
VALUES(argRoleName, argRoleType,argRoleSubType,argDetectionString,argComparisonOperator,argComparisonResult,argSerialKeyString,argProductKeyString,argRoleDetectionGuid,argIsRemote,argSearchId,argIsSupport,argParentRoleDefinitionGuid);
9
ELSE
10
Update RoleDefinitions
11
SET
12
RoleName = argRoleName, RoleType = argRoleType, RoleSubType = argRoleSubType, DetectionString = argDetectionString,
13
ComparisonOperator = argComparisonOperator, ComparisonResult = argComparisonResult, SerialKeyString = argSerialKeyString,
14
ProductKeyString = argProductKeyString, RoleDetectionGuid = argRoleDetectionGuid, IsRemote = argIsRemote, SearchId = argSearchId,
15
IsSupport = argIsSupport, ParentRoleDefinitionGuid = argParentRoleDefinitionGuid
16
WHERE
17
RoleDefinitionId = _existingRoleId;
18
END IF;
19
20
END