Hi All,
I have an initial Sybase query which pulls the unique key value. And I need to use this unique value into another query where I have to use this key in multiple different places in where condition.
Initial query:
Select Intial_ID from dbo.MasterTable where COB_Type = 'EOM'
Main Query:
SELECT * FROM ORSDBO.V_CASH_SEC_NETTING_SET
WHERE TIME_INV_KEY IN (IntialID)
) ANCHOR_NETTING_SETT RIGHT OUTER JOIN (
select * from ORSDBO.V_CASH_SEC_BRIDGE
where TIME_INV_KEY IN (110817220170630)
AND CASE WHEN COALESCE(SOURCE_FEED_NAME,'X') NOT IN ('CS_MRGN_PB_PSTN' ,'CS_MRGN_RETAIL_PSTN') THEN NETTED_EXPOSURE_IND ELSE 'MEMBER' END IN ('MEMBER','NOT NETTED','NO EXPOSURE','NOEXP-MEMBER','NOEXP-NOT NETTED')
) CASH_SEC_BRIDGE ON (CASH_SEC_BRIDGE.TIME_INV_KEY=ANCHOR_NETTING_SETT.TIME_INV_KEY and CASH_SEC_BRIDGE.TRADE_ODS_TYPE=ANCHOR_NETTING_SETT.ODS_TYPE and CASH_SEC_BRIDGE.TRADE_ODS_KEY=ANCHOR_NETTING_SETT.ODS_KEY)
INNER JOIN ORSDBO.V_DIM_CLIENT_MASK CLIENT_MASK_PO ON (CLIENT_MASK_PO.TIME_INV_KEY IN (110817220170630) AND CASH_SEC_BRIDGE.TIME_INV_KEY=CLIENT_MASK_PO.TIME_INV_KEY and CASH_SEC_BRIDGE.CTPTY_PARENT_ID=CLIENT_MASK_PO.CLNT_OID)
INNER JOIN ORSDBO.V_DIM_CLIENT_MASK CLIENT_CPTY ON (CASH_SEC_BRIDGE.TIME_INV_KEY=CLIENT_CPTY.TIME_INV_KEY and CASH_SEC_BRIDGE.CTPTY_CLIENT_LOOKUP_ID=CLIENT_CPTY.CLNT_OID AND CLIENT_CPTY.TIME_INV_KEY IN (110817220170630) )
INNER JOIN ORSDBO.V_DIM_CLIENT_MASK CLIENT_HO ON (CLIENT_HO.TIME_INV_KEY IN (110817220170630) AND CLIENT_HO.TIME_INV_KEY = CLIENT_CPTY.TIME_INV_KEY AND
CLIENT_HO.CLNT_OID = CLIENT_CPTY.HO_RESULT_OID)
INNER JOIN (
select * from ORSDBO.V_CASH_SEC_EXPOSURE
where TIME_INV_KEY IN (110817220170630)
and NETTED_EXPOSURE_IND IN ('MEMBER','NOT NETTED','NOEXP-MEMBER','NOEXP-NOT NETTED')
) CASH_SEC_EXPOSURE_POS ON (CASH_SEC_BRIDGE.TIME_INV_KEY=CASH_SEC_EXPOSURE_POS.TIME_INV_KEY and CASH_SEC_BRIDGE.EXPOSURE_ID=CASH_SEC_EXPOSURE_POS.EXPOSURE_ID)
INNER JOIN (
select * from ORSDBO.V_CASH_SEC_TRADE
where TIME_INV_KEY IN (110817220170630)
) CASH_SEC_TRADE ON (CASH_SEC_TRADE.TIME_INV_KEY=CASH_SEC_BRIDGE.TIME_INV_KEY and CASH_SEC_TRADE.ODS_KEY=CASH_SEC_BRIDGE.TRADE_ODS_KEY and CASH_SEC_TRADE.ODS_TYPE=CASH_SEC_BRIDGE.TRADE_ODS_TYPE )
So, where ever it has a value for Time_INV_KEY, I need to change that with the value what I got in my initial query. Can someone help me in this?
Solved! Go to Solution.
Check out the dynamic input tool, which you can pass parameters into.
I've not really worked with SQL databases too often but I know this would be a good start in order to bring through a query retrieved from the original input.
Ben
Look into the Dynamic Input tool. You can pass it a field and have it update your query. Below, I've put to replace a specific sting in your query, namely the TIME_INV_KEY you already have entered:
Hi,
Thanks for the reply, will let you know if I get any other issues while implementing this.