create table CIT_ADMIN.OBJECT_DETAIL_MASTER (
RULE_ID VARCHAR(10),
ATTR_1 VARCHAR(50),
ATTR_2 VARCHAR(50),
ATTR_3 VARCHAR(50),
CREATED_DATE DATE DEFAULT SYSDATE)
create table CIT_ADMIN.PRIORITY_RULE_FACTORY (
RULE_ID VARCHAR(10),
RULE_DESC VARCHAR(10),
RULE_1 VARCHAR(50),
RULE_2 VARCHAR(50),
RULE_3 VARCHAR(50),
CREATED_DATE DATE DEFAULT SYSDATE)
insert into CIT_ADMIN.PRIORITY_RULE_FACTORY
(RULE_ID, RULE_DESC, RULE_1, RULE_2, RULE_3)
values ('1', 'POSITION', 'ODS_KEY', 'NOTIONAL', 'SIK')
insert into CIT_ADMIN.PRIORITY_RULE_FACTORY
(RULE_ID, RULE_DESC, RULE_1, RULE_2, RULE_3)
values ('2', 'CLIENT', 'UCN', 'AGREEMENT_ID', 'FACILITY_ID')
insert into CIT_ADMIN.PRIORITY_RULE_FACTORY
(RULE_ID, RULE_DESC, RULE_1, RULE_2, RULE_3)
values ('3', 'NETTING', 'AGREEMENT_ID', 'AGREEMENT_AMT', 'MATURITY')
insert into CIT_ADMIN.OBJECT_DETAIL_MASTER
(RULE_ID, ATTR_1, ATTR_2, ATTR_3)
values ('1', '123', '1000', '600')
insert into CIT_ADMIN.OBJECT_DETAIL_MASTER
(RULE_ID, ATTR_1, ATTR_2, ATTR_3)
values ('2', '456', '2000', '500')
insert into CIT_ADMIN.OBJECT_DETAIL_MASTER
(RULE_ID, ATTR_1, ATTR_2, ATTR_3)
values ('3', '789', '3000', '400')
These are my tables. Rule id is foreign key in master table, also the primary key in rule factory table. I tried writing query that can link the rule with the data.
**Like:**
WITH ATTR AS (SELECT * FROM CIT_ADMIN.PRIORITY_RULE_FACTORY WHERE RULE_DESC = 'POSITION')
SELECT ATTR_2 FROM CIT_ADMIN.OBJECT_DETAIL_MASTER a
WHERE RULE_ID in (SELECT ATTR.RULE_ID FROM attr)
AND ATTR_1 = '123'
If I know position and ods_key I want Notional. This query fetched me that but the problem is i dont know the position of those attributes. Can you guys please give me some pointers to move ahead.!!!
Regards.