on 04-21-2013 11:51 AM
Please suggest best ways to write dynamice SQL condition as my requirement deals with 9 input parameters and there will be scenarios where values won't be passed for around 7 input parameters.
One option is by using IF ELSE statement and write separate SELECT statements accordingly which will increase the code lines as 7 parameters are considered. I saw blogs where EXECUTE IMMEDIATE is not suggested to use.
Hi Karthik,
Give a try playing with parameters and OR:
select
...
from
...
where (BUKRS = :p_bukrs OR :p_bukrs = '')
and (GJAHR = p_gjahr or :p_gjahr = '')
.....
In one case I tested I saw a performance degradation with these OR's but still acceptable.
You need to run into your scenarios to decide which is best for your case.
Regards, Fernando Da Rós
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.