I want to execute one of the two queries here based on a parameter.
The parameter could be a Yes/No Flag. Based on ‘Yes’ value, first query should get executed, and so as the second based on ‘No’.
SELECT per.PERSONAL_NUM as EMP_NUM,per.FIRST_NAME||' '||MIDDLE_NAME||' '||LAST_NAME AS NAME,per.EMPLOYEE_TYPE
FROM PER_EMPLOYEE_MST per
WHERE FIRST_NAME LIKE (:pname)||'%'
UNION ALL
SELECT dep.DEPUT_PERS_NUM as EMP_NUM,dep.FIRST_NAME||' '||MIDDLE_NAME||' '||LAST_NAME AS NAME,dep.EMPLOYEE_TYPE
FROM PER_DEPUTATION_MST dep
WHERE FIRST_NAME LIKE (:pname)||'%'
ORDER BY NAME
Make checking the flag part of the
WHEREclause of each part, so they will return no rows if they aren’t appropriate: