[Home] [Help]
1115: p_org_id in number) is
1116:
1117: begin
1118:
1119: insert into amw_risk_associations
1120: (RISK_ASSOCIATION_ID,
1121: RISK_ID,
1122: PK1,
1123: PK2,
1136: CREATED_BY,
1137: LAST_UPDATE_LOGIN,
1138: OBJECT_VERSION_NUMBER)
1139: (select
1140: AMW_RISK_ASSOCIATIONS_S.nextval,
1141: RISK_ID,
1142: p_org_id,
1143: PK1,
1144: RISK_LIKELIHOOD_CODE,
1155: sysdate,
1156: G_USER_ID,
1157: G_LOGIN_ID,
1158: 1
1159: from amw_risk_associations
1160: where PK1 = p_child_process_id
1161: and object_type = 'PROCESS'
1162: and approval_date is not null
1163: and deletion_approval_date is null);
1482:
1483: begin
1484:
1485: -- ko, We Don't want the draft associations to linger in the table..So delete them..
1486: delete amw_risk_associations
1487: where pk1 = p_org_id
1488: and pk2 = p_process_id
1489: and object_type = 'PROCESS_ORG'
1490: and approval_date is null;
1488: and pk2 = p_process_id
1489: and object_type = 'PROCESS_ORG'
1490: and approval_date is null;
1491:
1492: update amw_risk_associations
1493: set DELETION_DATE = sysdate
1494: where pk1 = p_org_id
1495: and pk2 = p_process_id
1496: and object_type = 'PROCESS_ORG'
2530: if x.exists(1) then
2531: forall ctr in x.first .. x.last
2532: update amw_process_organization
2533: set risk_count_latest = (select count(*) from (
2534: select distinct risk_id from amw_risk_associations
2535: where pk1 = p_org_id
2536: and pk2 in (
2537: select child_id
2538: from amw_latest_hierarchies
2712: if x.exists(1) then
2713: forall ctr in x.first .. x.last
2714: update amw_process_organization
2715: set risk_count = (select count(*) from (
2716: select distinct risk_id from amw_risk_associations
2717: where pk1 = p_org_id
2718: and pk2 in ( select child_id
2719: from amw_approved_hierarchies
2720: start with child_id = x(ctr) and organization_id = p_org_id
3046: if p_org_range_from is not null and p_org_range_to is not null then
3047:
3048: update amw_process_organization APO
3049: set APO.risk_count_latest = (
3050: select count(distinct ARA.risk_id) from amw_risk_associations ARA
3051: where ARA.pk1 = APO.ORGANIZATION_ID
3052: and ARA.pk2 in ( select alh.child_id
3053: from amw_latest_hierarchies alh
3054: start with alh.child_id = APO.PROCESS_ID and alh.organization_id = APO.ORGANIZATION_ID
3099: else
3100:
3101: update amw_process_organization APO
3102: set APO.risk_count_latest = (
3103: select count(distinct ARA.risk_id) from amw_risk_associations ARA
3104: where ARA.pk1 = APO.ORGANIZATION_ID
3105: and ARA.pk2 in ( select alh.child_id
3106: from amw_latest_hierarchies alh
3107: start with alh.child_id = APO.PROCESS_ID and alh.organization_id = APO.ORGANIZATION_ID
3166: if p_org_range_from is not null and p_org_range_to is not null then
3167:
3168: update amw_process_organization APO
3169: set APO.risk_count = (
3170: select count(distinct ARA.risk_id) from amw_risk_associations ARA
3171: where ARA.pk1 = APO.ORGANIZATION_ID
3172: and ARA.pk2 in ( select alh.child_id
3173: from amw_approved_hierarchies alh
3174: start with alh.child_id = APO.PROCESS_ID and alh.organization_id = APO.ORGANIZATION_ID
3227: else
3228:
3229: update amw_process_organization APO
3230: set APO.risk_count = (
3231: select count(distinct ARA.risk_id) from amw_risk_associations ARA
3232: where ARA.pk1 = APO.ORGANIZATION_ID
3233: and ARA.pk2 in ( select alh.child_id
3234: from amw_approved_hierarchies alh
3235: start with alh.child_id = APO.PROCESS_ID and alh.organization_id = APO.ORGANIZATION_ID
3594:
3595: forall ctr in l_orgs_tbl.first .. l_orgs_tbl.last
3596: update amw_process_organization
3597: set risk_count_latest = (select count(*) from (
3598: select distinct risk_id from amw_risk_associations
3599: where pk1 = l_orgs_tbl(ctr)
3600: and pk2 in (select alh.child_id
3601: from amw_latest_hierarchies alh
3602: start with alh.child_id = l_procs_tbl(ctr) and alh.organization_id = l_orgs_tbl(ctr)
3650:
3651: forall ctr in l_orgs_tbl.first .. l_orgs_tbl.last
3652: update amw_process_organization
3653: set risk_count = (select count(*) from (
3654: select distinct risk_id from amw_risk_associations
3655: where pk1 = l_orgs_tbl(ctr)
3656: and pk2 in ( select alh.child_id
3657: from amw_approved_hierarchies alh
3658: start with alh.child_id = l_procs_tbl(ctr) and alh.organization_id = l_orgs_tbl(ctr)
4915: end if;
4916:
4917: -- perform other common delete operations
4918:
4919: delete from amw_risk_associations
4920: where pk1 = p_organization_id
4921: and pk2 = p_process_id
4922: and approval_date is null
4923: and object_type = 'PROCESS_ORG';
4923: and object_type = 'PROCESS_ORG';
4924: IF SQL%FOUND THEN
4925: l_risk_exists := TRUE;
4926: END IF;
4927: update amw_risk_associations
4928: set deletion_date = null
4929: where pk1 = p_organization_id
4930: and pk2 = p_process_id
4931: and object_type = 'PROCESS_ORG'
5846: IF p_sync_rcm = 'SLIB' THEN
5847: -- Reflect the RCM list to be like that RL process..
5848: -- 1.First sync up the Risks....
5849: -- We Don't want the draft associations to linger in the table..So delete them..
5850: delete amw_risk_associations
5851: where pk1 = p_org_id
5852: and pk2 = p_process_id
5853: and object_type = 'PROCESS_ORG'
5854: and approval_date is null;
5852: and pk2 = p_process_id
5853: and object_type = 'PROCESS_ORG'
5854: and approval_date is null;
5855:
5856: update amw_risk_associations
5857: set DELETION_DATE = sysdate
5858: where pk1 = p_org_id
5859: and pk2 = p_process_id
5860: and object_type = 'PROCESS_ORG'
5859: and pk2 = p_process_id
5860: and object_type = 'PROCESS_ORG'
5861: and deletion_date is null
5862: and risk_id not in (select risk_id
5863: from amw_risk_associations
5864: where pk1 = p_process_id
5865: and object_type = 'PROCESS'
5866: and approval_date is not null
5867: and deletion_approval_date is null);
5865: and object_type = 'PROCESS'
5866: and approval_date is not null
5867: and deletion_approval_date is null);
5868: -- Now deleted all the risks that exists in org only but not in rl..Now copy all the risks that exists in rl only and not in org..
5869: insert into amw_risk_associations
5870: (RISK_ASSOCIATION_ID,
5871: RISK_ID,
5872: PK1,
5873: PK2,
5886: CREATED_BY,
5887: LAST_UPDATE_LOGIN,
5888: OBJECT_VERSION_NUMBER)
5889: (select
5890: AMW_RISK_ASSOCIATIONS_S.nextval,
5891: RISK_ID,
5892: p_org_id,
5893: PK1,
5894: RISK_LIKELIHOOD_CODE,
5905: sysdate,
5906: G_USER_ID,
5907: G_LOGIN_ID,
5908: 1
5909: from amw_risk_associations
5910: where PK1 = p_process_id
5911: and object_type = 'PROCESS'
5912: and approval_date is not null
5913: and deletion_approval_date is null
5911: and object_type = 'PROCESS'
5912: and approval_date is not null
5913: and deletion_approval_date is null
5914: and risk_id not in(select risk_id
5915: from amw_risk_associations
5916: where pk1 = p_org_id
5917: and pk2 = p_process_id
5918: and object_type = 'PROCESS_ORG'
5919: and deletion_date is null));
6201: ELSIF p_sync_rcm = 'ARCM' THEN
6202:
6203: -- WE JUST NEED TO ADD THE NEWLY ADDED RISKS/CONTROLS/AUDIT PROCEDURES TO THE PROCESS..
6204: -- so Add Risks..
6205: insert into amw_risk_associations
6206: (RISK_ASSOCIATION_ID,
6207: RISK_ID,
6208: PK1,
6209: PK2,
6222: CREATED_BY,
6223: LAST_UPDATE_LOGIN,
6224: OBJECT_VERSION_NUMBER)
6225: (select
6226: AMW_RISK_ASSOCIATIONS_S.nextval,
6227: RISK_ID,
6228: p_org_id,
6229: PK1,
6230: RISK_LIKELIHOOD_CODE,
6241: sysdate,
6242: G_USER_ID,
6243: G_LOGIN_ID,
6244: 1
6245: from amw_risk_associations
6246: where PK1 = p_process_id
6247: and object_type = 'PROCESS'
6248: and approval_date is not null
6249: and deletion_approval_date is null
6247: and object_type = 'PROCESS'
6248: and approval_date is not null
6249: and deletion_approval_date is null
6250: and risk_id not in(select risk_id
6251: from amw_risk_associations
6252: where pk1 = p_org_id
6253: and pk2 = p_process_id
6254: and object_type = 'PROCESS_ORG'
6255: and deletion_date is null));
6488: -- 1.First sync up the Risks....
6489: -- We Don't want the draft associations to linger in the table..So delete them..
6490:
6491: FORALL indx IN Org_Ids.FIRST .. Org_Ids.LAST
6492: delete amw_risk_associations
6493: where pk1 = Org_Ids(indx)
6494: and pk2 = p_process_id
6495: and object_type = 'PROCESS_ORG'
6496: and approval_date is null;
6495: and object_type = 'PROCESS_ORG'
6496: and approval_date is null;
6497:
6498: FORALL indx IN Org_Ids.FIRST .. Org_Ids.LAST
6499: update amw_risk_associations
6500: set DELETION_DATE = sysdate
6501: where pk1 = Org_Ids(indx)
6502: and pk2 = p_process_id
6503: and object_type = 'PROCESS_ORG'
6502: and pk2 = p_process_id
6503: and object_type = 'PROCESS_ORG'
6504: and deletion_date is null
6505: and risk_id not in (select risk_id
6506: from amw_risk_associations
6507: where pk1 = p_process_id
6508: and object_type = 'PROCESS'
6509: and approval_date is not null
6510: and deletion_approval_date is null);
6509: and approval_date is not null
6510: and deletion_approval_date is null);
6511: -- Now deleted all the risks that exists in org only but not in rl..Now copy all the risks that exists in rl only and not in org..
6512: FORALL indx IN Org_Ids.FIRST .. Org_Ids.LAST
6513: insert into amw_risk_associations
6514: (RISK_ASSOCIATION_ID,
6515: RISK_ID,
6516: PK1,
6517: PK2,
6530: CREATED_BY,
6531: LAST_UPDATE_LOGIN,
6532: OBJECT_VERSION_NUMBER)
6533: (select
6534: AMW_RISK_ASSOCIATIONS_S.nextval,
6535: RISK_ID,
6536: Org_Ids(indx),
6537: PK1,
6538: RISK_LIKELIHOOD_CODE,
6549: sysdate,
6550: G_USER_ID,
6551: G_LOGIN_ID,
6552: 1
6553: from amw_risk_associations
6554: where PK1 = p_process_id
6555: and object_type = 'PROCESS'
6556: and approval_date is not null
6557: and deletion_approval_date is null
6555: and object_type = 'PROCESS'
6556: and approval_date is not null
6557: and deletion_approval_date is null
6558: and risk_id not in (select risk_id
6559: from amw_risk_associations
6560: where pk1 = Org_Ids(indx)
6561: and pk2 = p_process_id
6562: and object_type = 'PROCESS_ORG'
6563: and deletion_date is null));
6802:
6803: -- WE JUST NEED TO ADD THE NEWLY ADDED RISKS/CONTROLS/AUDIT PROCEDURES TO THE PROCESS..
6804: -- so Add Risks..
6805: FORALL indx IN Org_Ids.FIRST .. Org_Ids.LAST
6806: insert into amw_risk_associations
6807: (RISK_ASSOCIATION_ID,
6808: RISK_ID,
6809: PK1,
6810: PK2,
6823: CREATED_BY,
6824: LAST_UPDATE_LOGIN,
6825: OBJECT_VERSION_NUMBER)
6826: (select
6827: AMW_RISK_ASSOCIATIONS_S.nextval,
6828: RISK_ID,
6829: Org_Ids(indx),
6830: PK1,
6831: RISK_LIKELIHOOD_CODE,
6842: sysdate,
6843: G_USER_ID,
6844: G_LOGIN_ID,
6845: 1
6846: from amw_risk_associations
6847: where PK1 = p_process_id
6848: and object_type = 'PROCESS'
6849: and approval_date is not null
6850: and deletion_approval_date is null
6848: and object_type = 'PROCESS'
6849: and approval_date is not null
6850: and deletion_approval_date is null
6851: and risk_id not in (select risk_id
6852: from amw_risk_associations
6853: where pk1 = Org_Ids(indx)
6854: and pk2 = p_process_id
6855: and object_type = 'PROCESS_ORG'
6856: and deletion_date is null));