This question is regarding PLSQL - for improving the efficiency of the code and coding standards.
Any help, pointers, references or suggestions are highly appreciated.
Question:
I have a plsql procedure with an INPUT parameter i_flag
which is of type BOOLEAN
.
Based upon the value of this i_flag( which can be either true or false) I have to execute a sql query. If the value is TRUE
then SQL1 (Assume query 1.1) else if the value is FALSE
SQL2 (Assume query 1.2) would be executed.
SQL2 is same as SQL1 except an addition of where clause.
SQL1 (1.1)
select a.user_id, a.user_name, a.dept_id, b.country from user a , contact b
where a.user_id = b.user_id;
SQL1 (1.2)
select a.user_id, a.user_name, a.dept_id, b.country from user a , contact b
where a.user_id = b.user_id
and a.user_status is not null;
Instead of writing IF-ELSE in plsql is it possible to write this query in a single SQL query?