317: descriptionCount varchar2(500);
318: begin
319: select count(*)
320: into descriptionCount
321: from ame_rules
322: where upper(description) = upper(descriptionIn) and
323: /* allows for future start date */
324: ((sysdate between start_date and
325: nvl(end_date - ame_util.oneSecond, sysdate)) or
460: begin
461: if processingDateIn is null then
462: select item_class_id
463: into itemClassId
464: from ame_rules
465: where
466: rule_id = ruleIdIn and
467: ((sysdate between start_date and
468: nvl(end_date - ame_util.oneSecond, sysdate)) or
471: return(itemClassId);
472: else
473: select item_class_id
474: into itemClassId
475: from ame_rules
476: where
477: rule_id = ruleIdIn and
478: rownum < 2 and /* for efficiency */
479: (processingDateIn between start_date and
608: begin
609: if processingDateIn is null then
610: select rule_type
611: into ruleType
612: from ame_rules
613: where
614: rule_id = ruleIdIn and
615: ((sysdate between start_date and
616: nvl(end_date - ame_util.oneSecond, sysdate)) or
619: return(ruleType);
620: else
621: select rule_type
622: into ruleType
623: from ame_rules
624: where
625: rule_id = ruleIdIn and
626: rownum < 2 and /* for efficiency */
627: (processingDateIn between start_date and
705: return(null);
706: end getRuleTypeLabel2;
707: function getDescription(ruleIdIn in integer,
708: processingDateIn in date default null) return varchar2 as
709: description ame_rules.description%type;
710: begin
711: if processingDateIn is null then
712: select description
713: into description
710: begin
711: if processingDateIn is null then
712: select description
713: into description
714: from ame_rules
715: where
716: rule_id = ruleIdIn and
717: rownum < 2 and /* for efficiency */
718: ((sysdate between start_date and
721: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
722: else
723: select description
724: into description
725: from ame_rules
726: where
727: rule_id = ruleIdIn and
728: rownum < 2 and /* for efficiency */
729: (processingDateIn between start_date and
743: raise;
744: return(null);
745: end getDescription;
746: function getEndDate(ruleIdIn in integer) return date as
747: endDate ame_rules.end_date%type;
748: begin
749: select end_date
750: into endDate
751: from ame_rules
747: endDate ame_rules.end_date%type;
748: begin
749: select end_date
750: into endDate
751: from ame_rules
752: where
753: rule_id = ruleIdIn and
754: ((sysdate between start_date and
755: nvl(end_date - ame_util.oneSecond, sysdate)) or
867: conditionIdListIn in ame_util.idList,
868: actionIdListIn in ame_util.idList) return integer as
869: cursor ruleIdCursor(typeIn in varchar2) is
870: select rule_id
871: from ame_rules
872: where
873: rule_type = typeIn and
874: ((sysdate between start_date and
875: nvl(end_date - ame_util.oneSecond, sysdate)) or
880: actionIdMatch boolean;
881: conditionIdList1 ame_util.idList;
882: conditionIdList2 ame_util.idList;
883: conditionIdMatch boolean;
884: ruleId ame_rules.rule_id%type;
885: begin
886: ruleId := null;
887: conditionIdList1 := conditionIdListIn;
888: actionIdList1 := actionIdListIn;
964: ruleCount integer;
965: begin
966: select count(*)
967: into ruleCount
968: from ame_rules
969: where upper(rule_key) = upper(ruleKeyIn) and
970: rownum < 2;
971: if ruleCount > 0 then
972: return(true);
987: return(true);
988: end ruleKeyExists;
989: function getNextRuleKey return varchar2 as
990: databaseId varchar2(50);
991: newRuleKey ame_rules.rule_key%type;
992: newRuleKey1 ame_rules.rule_key%type;
993: ruleKeyId number;
994: seededKeyPrefix varchar2(4);
995: begin
988: end ruleKeyExists;
989: function getNextRuleKey return varchar2 as
990: databaseId varchar2(50);
991: newRuleKey ame_rules.rule_key%type;
992: newRuleKey1 ame_rules.rule_key%type;
993: ruleKeyId number;
994: seededKeyPrefix varchar2(4);
995: begin
996: begin
1034: return(null);
1035: end getNextRuleKey;
1036: function getRuleKey(ruleIdIn in integer,
1037: processingDateIn in date default null) return varchar2 as
1038: ruleKey ame_rules.rule_key%type;
1039: begin
1040: if processingDateIn is null then
1041: select rule_key
1042: into ruleKey
1039: begin
1040: if processingDateIn is null then
1041: select rule_key
1042: into ruleKey
1043: from ame_rules
1044: where
1045: rule_id = ruleIdIn and
1046: ((sysdate between start_date and
1047: nvl(end_date - ame_util.oneSecond, sysdate)) or
1049: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1050: else
1051: select rule_key
1052: into ruleKey
1053: from ame_rules
1054: where
1055: rule_id = ruleIdIn and
1056: (processingDateIn between start_date and
1057: nvl(end_date - ame_util.oneSecond, processingDateIn)) ;
1195: raise;
1196: return(ame_util.disabledRulePriority); /* safe */
1197: end getRulePriorityMode;
1198: function getStartDate(ruleIdIn in integer) return date as
1199: startDate ame_rules.start_date%type;
1200: begin
1201: select start_date
1202: into startDate
1203: from ame_rules
1199: startDate ame_rules.start_date%type;
1200: begin
1201: select start_date
1202: into startDate
1203: from ame_rules
1204: where
1205: rule_id = ruleIdIn and
1206: ((sysdate between start_date and
1207: nvl(end_date - ame_util.oneSecond, sysdate)) or
1294: raise;
1295: return(null);
1296: end getUsageStartDate;
1297: function getType(ruleIdIn in integer) return integer as
1298: ruleType ame_rules.rule_type%type;
1299: begin
1300: select rule_type
1301: into ruleType
1302: from ame_rules
1298: ruleType ame_rules.rule_type%type;
1299: begin
1300: select rule_type
1301: into ruleType
1302: from ame_rules
1303: where
1304: rule_id = ruleIdIn and
1305: ((sysdate between start_date and
1306: nvl(end_date - ame_util.oneSecond, sysdate)) or
1325: stringStartDate varchar2(50);
1326: begin
1327: select start_date
1328: into startDate
1329: from ame_rules
1330: where
1331: rule_id = ruleIdIn and
1332: ((sysdate between start_date and
1333: nvl(end_date - ame_util.oneSecond, sysdate)) or
1787: /* misc preparation for inserts */
1788: if(lengthb(ruleKeyIn) > 100) then
1789: raise ruleKeyLengthException;
1790: end if;
1791: if(ame_util.isArgumentTooLong(tableNamein => 'ame_rules',
1792: columnNamein => 'description',
1793: argumentin => descriptionIn)) then
1794: raise descriptionLengthException;
1795: end if;
1805: if(ame_util.getHighestResponsibility = ame_util.developerResponsibility) then
1806: /* Use negative rule IDs for developer-seeded rules. */
1807: select count(*)
1808: into ruleCount
1809: from ame_rules
1810: where
1811: ((sysdate between start_date and
1812: nvl(end_date - ame_util.oneSecond, sysdate)) or
1813: (sysdate < start_date and
1816: ruleId := -1;
1817: else
1818: select min(rule_id) - 1
1819: into ruleId
1820: from ame_rules
1821: where
1822: ((sysdate between start_date and
1823: nvl(end_date - ame_util.oneSecond, sysdate)) or
1824: (sysdate < start_date and
1827: ruleId := -1;
1828: end if;
1829: end if;
1830: else
1831: select ame_rules_s.nextval into ruleId from dual;
1832: end if;
1833: else
1834: ruleId := ruleIdIn;
1835: select count(*)
1833: else
1834: ruleId := ruleIdIn;
1835: select count(*)
1836: into tempCount
1837: from ame_rules
1838: where
1839: rule_id = ruleId and
1840: created_by = ame_util.seededDataCreatedById;
1841: if(tempCount > 0) then
1844: createdBy := currentUserId;
1845: end if;
1846: end if;
1847: /* inserts */
1848: insert into ame_rules(rule_id,
1849: rule_type,
1850: rule_key,
1851: action_id,
1852: created_by,
1959: errorCode := -20001;
1960: errorMessage := ame_util.getMessage(applicationShortNameIn => 'PER',
1961: messageNameIn => 'AME_400207_RUL_DESC_LONG',
1962: tokenNameOneIn => 'COLUMN_LENGTH',
1963: tokenValueOneIn => ame_util.getColumnLength(tableNamein => 'ame_rules',
1964: columnNamein => 'description'));
1965: ame_util.runtimeException(packageNamein => 'ame_rule_pkg',
1966: routineNamein => 'new',
1967: exceptionNumberIn => errorCode,
2083: processingDateIn in date default null,
2084: updateParentObjectIn in boolean default false) return boolean as
2085: cursor startDateCursor is
2086: select start_date
2087: from ame_rules
2088: where
2089: rule_id = ruleIdIn and
2090: ((sysdate between start_date and
2091: nvl(end_date - ame_util.oneSecond, sysdate)) or
2092: (sysdate < start_date and
2093: start_date < nvl(end_date,start_date + ame_util.oneSecond)))
2094: for update;
2095: actionIdList ame_util.idList;
2096: description ame_rules.description%type;
2097: approvalCategory ame_util.stringType;
2098: conditionIdList ame_util.idList;
2099: createdBy integer;
2100: createUsage boolean;
2098: conditionIdList ame_util.idList;
2099: createdBy integer;
2100: createUsage boolean;
2101: currentUserId integer;
2102: newRuleEndDate ame_rules.end_date%type;
2103: newRuleStartDate ame_rules.start_date%type;
2104: errorCode integer;
2105: errorMessage ame_util.longestStringType;
2106: invalidDateException exception;
2099: createdBy integer;
2100: createUsage boolean;
2101: currentUserId integer;
2102: newRuleEndDate ame_rules.end_date%type;
2103: newRuleStartDate ame_rules.start_date%type;
2104: errorCode integer;
2105: errorMessage ame_util.longestStringType;
2106: invalidDateException exception;
2107: itemClassId integer;
2107: itemClassId integer;
2108: itemIdCount integer;
2109: objectVersionNoDataException exception;
2110: invalidPriorityException exception;
2111: ruleKey ame_rules.rule_key%type;
2112: ruleId ame_rules.rule_id%type;
2113: ruleType ame_rules.rule_type%type;
2114: ruleStartDate date;
2115: usageExistsException exception;
2108: itemIdCount integer;
2109: objectVersionNoDataException exception;
2110: invalidPriorityException exception;
2111: ruleKey ame_rules.rule_key%type;
2112: ruleId ame_rules.rule_id%type;
2113: ruleType ame_rules.rule_type%type;
2114: ruleStartDate date;
2115: usageExistsException exception;
2116: startDateException exception;
2109: objectVersionNoDataException exception;
2110: invalidPriorityException exception;
2111: ruleKey ame_rules.rule_key%type;
2112: ruleId ame_rules.rule_id%type;
2113: ruleType ame_rules.rule_type%type;
2114: ruleStartDate date;
2115: usageExistsException exception;
2116: startDateException exception;
2117: startDateException1 exception;
2296: (processingDate < start_date and
2297: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2298: end loop;
2299: end if;
2300: update ame_rules
2301: set
2302: last_updated_by = currentUserId,
2303: last_update_date = processingDate,
2304: last_update_login = currentUserId,
2579: itemClassIdIn in integer default null) return boolean as
2580: cursor ruleIdCursor(typeIn in varchar2,
2581: applicationIdIn in integer,
2582: itemClassIdIn in integer default null) is
2583: select ame_rules.rule_id
2584: from ame_rules,
2585: ame_rule_usages
2586: where
2587: item_id = applicationIdIn and
2580: cursor ruleIdCursor(typeIn in varchar2,
2581: applicationIdIn in integer,
2582: itemClassIdIn in integer default null) is
2583: select ame_rules.rule_id
2584: from ame_rules,
2585: ame_rule_usages
2586: where
2587: item_id = applicationIdIn and
2588: rule_type = typeIn and
2587: item_id = applicationIdIn and
2588: rule_type = typeIn and
2589: (item_class_id is null or
2590: item_class_id = itemClassIdIn) and
2591: ame_rules.rule_id = ame_rule_usages.rule_id and
2592: ((sysdate between ame_rules.start_date and
2593: nvl(ame_rules.end_date - ame_util.oneSecond, sysdate)) or
2594: (sysdate < ame_rules.start_date and
2595: ame_rules.start_date < nvl(ame_rules.end_date,
2588: rule_type = typeIn and
2589: (item_class_id is null or
2590: item_class_id = itemClassIdIn) and
2591: ame_rules.rule_id = ame_rule_usages.rule_id and
2592: ((sysdate between ame_rules.start_date and
2593: nvl(ame_rules.end_date - ame_util.oneSecond, sysdate)) or
2594: (sysdate < ame_rules.start_date and
2595: ame_rules.start_date < nvl(ame_rules.end_date,
2596: ame_rules.start_date + ame_util.oneSecond))) and
2589: (item_class_id is null or
2590: item_class_id = itemClassIdIn) and
2591: ame_rules.rule_id = ame_rule_usages.rule_id and
2592: ((sysdate between ame_rules.start_date and
2593: nvl(ame_rules.end_date - ame_util.oneSecond, sysdate)) or
2594: (sysdate < ame_rules.start_date and
2595: ame_rules.start_date < nvl(ame_rules.end_date,
2596: ame_rules.start_date + ame_util.oneSecond))) and
2597: ((sysdate between ame_rule_usages.start_date and
2590: item_class_id = itemClassIdIn) and
2591: ame_rules.rule_id = ame_rule_usages.rule_id and
2592: ((sysdate between ame_rules.start_date and
2593: nvl(ame_rules.end_date - ame_util.oneSecond, sysdate)) or
2594: (sysdate < ame_rules.start_date and
2595: ame_rules.start_date < nvl(ame_rules.end_date,
2596: ame_rules.start_date + ame_util.oneSecond))) and
2597: ((sysdate between ame_rule_usages.start_date and
2598: nvl(ame_rule_usages.end_date - ame_util.oneSecond, sysdate)) or
2591: ame_rules.rule_id = ame_rule_usages.rule_id and
2592: ((sysdate between ame_rules.start_date and
2593: nvl(ame_rules.end_date - ame_util.oneSecond, sysdate)) or
2594: (sysdate < ame_rules.start_date and
2595: ame_rules.start_date < nvl(ame_rules.end_date,
2596: ame_rules.start_date + ame_util.oneSecond))) and
2597: ((sysdate between ame_rule_usages.start_date and
2598: nvl(ame_rule_usages.end_date - ame_util.oneSecond, sysdate)) or
2599: (sysdate < ame_rule_usages.start_date and
2592: ((sysdate between ame_rules.start_date and
2593: nvl(ame_rules.end_date - ame_util.oneSecond, sysdate)) or
2594: (sysdate < ame_rules.start_date and
2595: ame_rules.start_date < nvl(ame_rules.end_date,
2596: ame_rules.start_date + ame_util.oneSecond))) and
2597: ((sysdate between ame_rule_usages.start_date and
2598: nvl(ame_rule_usages.end_date - ame_util.oneSecond, sysdate)) or
2599: (sysdate < ame_rule_usages.start_date and
2600: ame_rule_usages.start_date < nvl(ame_rule_usages.end_date,
2604: actionIdMatch boolean;
2605: conditionIdList1 ame_util.idList;
2606: conditionIdList2 ame_util.idList;
2607: conditionIdMatch boolean;
2608: ruleId ame_rules.rule_id%type;
2609: begin
2610: ruleId := null;
2611: conditionIdList1 := conditionIdListIn;
2612: ame_util.sortIdListInPlace(idListInOut => conditionIdList1);
2664: itemClassIdIn in integer default null) return boolean as
2665: cursor ruleIdCursor(typeIn in varchar2,
2666: itemClassIdIn in integer default null) is
2667: select rule_id
2668: from ame_rules
2669: where
2670: rule_type = typeIn and
2671: (item_class_id is null or
2672: item_class_id = itemClassIdIn) and
2679: actionIdMatch boolean;
2680: conditionIdList1 ame_util.idList;
2681: conditionIdList2 ame_util.idList;
2682: conditionIdMatch boolean;
2683: ruleId ame_rules.rule_id%type;
2684: begin
2685: ruleId := null;
2686: conditionIdList1 := conditionIdListIn;
2687: ame_util.sortIdListInPlace(idListInOut => conditionIdList1);
2859: finalizeIn in boolean default false,
2860: processingDateIn in date default null) as
2861: cursor ruleStartDateCursor is
2862: select start_date
2863: from ame_rules
2864: where
2865: rule_id = ruleIdIn and
2866: ((sysdate between start_date and
2867: nvl(end_date - ame_util.oneSecond, sysdate)) or
2881: applicationIds ame_util.idList;
2882: conditionId integer;
2883: conditionIdListCopy ame_util.idList;
2884: currentUserId integer;
2885: description ame_rules.description%type;
2886: endDate date;
2887: errorCode integer;
2888: errorMessage ame_util.longestStringType;
2889: exceptionConditionException exception;
2897: newUsageResult boolean;
2898: nonProductionActionException exception;
2899: objectVersionNoDataException exception;
2900: ruleId integer;
2901: ruleKey ame_rules.rule_key%type;
2902: ruleType integer;
2903: ruleStartDate ame_rules.start_date%type;
2904: ruleEndDate ame_rules.end_date%type;
2905: tempCount integer;
2899: objectVersionNoDataException exception;
2900: ruleId integer;
2901: ruleKey ame_rules.rule_key%type;
2902: ruleType integer;
2903: ruleStartDate ame_rules.start_date%type;
2904: ruleEndDate ame_rules.end_date%type;
2905: tempCount integer;
2906: tempIndex2 integer;
2907: processingDate date;
2900: ruleId integer;
2901: ruleKey ame_rules.rule_key%type;
2902: ruleType integer;
2903: ruleStartDate ame_rules.start_date%type;
2904: ruleEndDate ame_rules.end_date%type;
2905: tempCount integer;
2906: tempIndex2 integer;
2907: processingDate date;
2908: newVersionStartDate date;
2936: end if;
2937: currentUserId := ame_util.getCurrentUserId;
2938: /* make sure the end_date and start_date values do not overlap */
2939: endDate := processingDate ;
2940: /* To figure out the start_date for the new row in ame_rules the
2941: logic is : If no value of start date is inputed in the routine then
2942: start date is not changed, then for future dated rules, the start_date
2943: is retained otherwise it becomes the processing date */
2944: if(trunc(ruleStartDate) > trunc(processingDate)) then
2945: newStartDate := trunc(ruleStartDate);
2946: else
2947: newStartDate := processingDate;
2948: end if;
2949: /* To figure out the end date for the new row in ame_rules the logic
2950: is: If no value for end_date is inputed in the routine then end date
2951: is not changed. In this case the end_date from the old row is retained
2952: */
2953: ruleEndDate := getEndDate(ruleIdIn => ruleIdIn);
3069: ((sysdate between start_date and
3070: nvl(end_date - ame_util.oneSecond, sysdate)) or
3071: (sysdate < start_date and
3072: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3073: update ame_rules
3074: set
3075: last_updated_by = currentUserId,
3076: last_update_date = endDate,
3077: last_update_login = currentUserId,
3357: finalizeIn in boolean default false,
3358: processingDateIn in date default null) as
3359: cursor startDateCursor is
3360: select start_date
3361: from ame_rules
3362: where
3363: rule_id = ruleIdIn and
3364: ((sysdate between start_date and
3365: nvl(end_date - ame_util.oneSecond, sysdate)) or
3807: r.item_class_id,
3808: u.approver_category
3809: from
3810: ame_rule_usages u,
3811: ame_rules r,
3812: ame_item_class_usages i
3813: where
3814: u.rule_id = r.rule_id and
3815: r.item_class_id = i.item_class_id and
3840: null item_class_id,
3841: u.approver_category
3842: from
3843: ame_rule_usages u,
3844: ame_rules r
3845: where
3846: u.rule_id = r.rule_id and
3847: r.rule_type in (ame_util.substitutionRuleType, ame_util.listModRuleType) and
3848: u.item_id = applicationIdIn and
3909: select
3910: distinct(r.rule_id) rule_id,
3911: r.description
3912: from
3913: ame_rules r,
3914: ame_rule_usages u
3915: where
3916: u.rule_id = r.rule_id and
3917: (r.item_class_id is null or
4010: conditionIdList ame_util.idList;
4011: tempConditionType ame_conditions.condition_type%type;
4012: tempDescription varchar2(200);
4013: upperLimit integer;
4014: ruleType ame_rules.rule_type%type;
4015: begin
4016: ruleType := getRuleType(ruleIdIn => ruleIdIn);
4017: getConditionIds(ruleIdIn => ruleIdIn,
4018: conditionIdListOut => conditionIdList);
4061: begin
4062: ruleIdCount := ruleIdsIn.count;
4063: for i in 1..ruleIdCount loop
4064: detailUrlsOut(i) := (ame_util.getPlsqlDadPath ||
4065: 'ame_rules_ui.getDetails?ruleIdIn=' ||
4066: ruleIdsIn(i) ||
4067: '&applicationIdIn=' ||
4068: applicationIdIn ||
4069: '&displayUsagesIn=' ||
4460: conditionIdIn => conditionIdList(tempIndex),
4461: finalizeIn => finalizeIn);
4462: end loop;
4463: currentUserId := ame_util.getCurrentUserId;
4464: update ame_rules
4465: set
4466: last_updated_by = currentUserId,
4467: last_update_date = sysdate,
4468: last_update_login = currentUserId,
4553: finalizeIn in boolean default true,
4554: processingDateIn in date default null) as
4555: cursor startDateCursor is
4556: select start_date
4557: from ame_rules
4558: where
4559: rule_id = ruleIdIn and
4560: ((sysdate between start_date and
4561: nvl(end_date - ame_util.oneSecond, sysdate)) or
4567: attributeIdList ame_util.idList;
4568: conditionCount integer;
4569: conditionIdList ame_util.idList;
4570: currentUserId integer;
4571: description ame_rules.description%type;
4572: newRuleEndDate ame_rules.end_date%type;
4573: endDate date;
4574: processingDate date;
4575: errorCode integer;
4568: conditionCount integer;
4569: conditionIdList ame_util.idList;
4570: currentUserId integer;
4571: description ame_rules.description%type;
4572: newRuleEndDate ame_rules.end_date%type;
4573: endDate date;
4574: processingDate date;
4575: errorCode integer;
4576: errorMessage ame_util.longestStringType;
4575: errorCode integer;
4576: errorMessage ame_util.longestStringType;
4577: itemClassId integer;
4578: objectVersionNoDataException exception;
4579: ruleId ame_rules.rule_id%type;
4580: ruleKey ame_rules.rule_key%type;
4581: ruleType ame_rules.rule_type%type;
4582: startDate date;
4583: begin
4576: errorMessage ame_util.longestStringType;
4577: itemClassId integer;
4578: objectVersionNoDataException exception;
4579: ruleId ame_rules.rule_id%type;
4580: ruleKey ame_rules.rule_key%type;
4581: ruleType ame_rules.rule_type%type;
4582: startDate date;
4583: begin
4584: /* check to see if processingDate has been initialized */
4577: itemClassId integer;
4578: objectVersionNoDataException exception;
4579: ruleId ame_rules.rule_id%type;
4580: ruleKey ame_rules.rule_key%type;
4581: ruleType ame_rules.rule_type%type;
4582: startDate date;
4583: begin
4584: /* check to see if processingDate has been initialized */
4585: if processingDateIn is null then
4672: ame_admin_pkg.updateStripingAttUseCount(applicationIdIn => itemIdIn);
4673: end if;
4674: */
4675: else
4676: update ame_rules
4677: set
4678: last_updated_by = currentUserId,
4679: last_update_date = processingDate,
4680: last_update_login = currentUserId,