I have three tables, viz:
- Mains_Control
- Control_Mapping
- Control_Details
along with several conditions and columns. But I am performing dynamic operations on the tables columns given below.
I am unable to write a dynamic SQL block in PL-SQL procedure for the below conditions. Could anyone please assist me on this particular scenario.
SELECT *
FROM CUR_ALL_CONTENTS
WHERE MAINS_CONTROL SWITCH = $SWITCH
AND ($ATTRIB_COLUMNS = $ATTRIB_VAL
OR $ATTRIB_COLUMNS = $ATTRIB_VAL)
The above business condition is this
SELECT *
FROM CUR_ALL_CONTENTS
WHERE MAINS_CONTROL_SWITCH = 'TYPE'
AND (SWITCH_MODE = 'THRUST' OR SWITCH_MODE_GEAR = 'SEC_GEAR')
Here SWITCH attribute value can change, ATTRIB_COLUMNS and ATTRIB_VAL can change.
- Mains_Control table has the following columns
SWITCH ACTION_CODE RULE_MAP_1
TYPE ON R1
TYPE OFF R2
METHOD HOLD R3
METHOD TERM_IN R4
- Control_Mapping table has the following columns
RULE_MAP_1 RULE_MAP_2
R1 M11
R2 M22
R3 M33
R4 M44
- Control_Details table has the following columns
RULE_MAP_2 ATTRIB_COLUMNS OPERAND ATTRIB_VAL
M11 SWTICH_MODE = THRUST
M22 SWITCH_MODE_GEAR = SEC_GEAR
M33 HOLD_RELEASE <> END