Skip to content
Advertisement

Need assistance with IF ELSE condition in Oracle

I have a list of tables, i need to pass those table based on column name. For example if my table has CLASSID it will go block 2, if table has OBJID it will go block 1, if table has KOPPKT it will go block 3, but if any table has CLASSID and OBJID both, it should go block 2 not block 1.
Similarly if any table has KOPPKT and OBJID it should go block 1 not block 3. Here i am facing issue to send tables into proper block.
The code i am trying to achieve but not getting the desired output.

Here Table1 and table2 should go block 2 as it has CLASSID, table3 should go block 1 as it has OBJID

Passing Table1 first output i got. which means it goes both block 2 and block 3.but i want to pass only block2

Similarly if I pass Table 2 I am getting this. which means it goes both block 1 and block 2.but i want to pass only block2

Similarly if I pass Table 3 I am getting this. which means it goes both block 1 and block 3.but i want to pass only block2

I have tried with below condition also still it not working

Advertisement

Answer

Find all the columns of interest for your table with LISTAGG and then check for individual combinations in CASE statement. Put condition on CLASSID before condition on CLASSID and something:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement