For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
We're on EBS 12.2.5. Our auditors have requested data extracts of our Journal Entries, Trial Balance, Chart of Accounts, etc. Is there a standard way in Oracle EBS to do this? Any 3rd party tools?
You can write it down explicitly like this:
select * from employee_view where :p_cnic = 'YES' and emp_cnic is not null or :p_cnic = 'NO' and emp_cnic is null
undefined (0 Bytes) Whilst order of precedence works, for clarity of reading (and to ensure future lazy developers don't break it so easily), I always prefer to use parentheses/brackets around my OR clauses...
select * from employee_view where ( :p_cnic = 'YES' and emp_cnic is not null ) or ( :p_cnic = 'NO' and emp_cnic is null )
Just makes it absolutely clear which clauses belong with which other clauses. Nothing worse than a future developer coming along adding another "and" clause thinking it will apply to everything but they've not seen the OR statement and then it's not working as it should.
Hi Muhammad, here's a little correction of the query of cormaco and BluShadow to satisfy your requirement to select all records if no value is passed:
SELECT * FROM employee_view WHERE ( :p_cnic = 'YES' AND emp_cnic IS NOT NULL) OR ( :p_cnic = 'NO' AND emp_cnic IS NULL) OR ( :p_cnic IS NULL)
Best regards Jan
Hi Cormaco after little bit change giving me right answer such as select emp_id,emp_name,emp_cnic from employee_view a where a.emp_id in ( select distinct emp_id from hml_emp_attend_register where month_id = :p_month ) and ( (:p_cnic = 'YES' and emp_cnic is not null) or ( :p_cnic = 'NO' and emp_cnic is null) ) Many thanks Jan n Blue Shadow
Hi, [Muhammad Masoom Ansari](/ords/forums/user/Muhammad Masoom Ansari) Here's another way to write the WHERE clause, that's a little more concise:
WHERE :p_cnis IS NULL OR :p_cnis = NVL2 (emp_cnis, 'YES', 'NO')
I tried with decode function but I think it don't support the "not null" Right. DECODE must return a value in one of the SQL data types, such as VARCHAR2 or NUMBER. That means, the 3rd, 5th, ... arguments must all be expressions that result in the same kind of SQL data type. But emp_cnis is not null is a BOOLEAN expression, and there is no BOOLEAN data type in SQL.
Hi Muhammad, be aware that your "... all records should be viewed" requirement is not met by your query. Best regards Jan
@frank-kulash a little more concise lnnvl(:p_cnis = NVL2 (emp_cnis, 'NO', 'YES'))
lnnvl(:p_cnis = NVL2 (emp_cnis, 'NO', 'YES'))
Hi @Jan Gorkow Thank you very much for pointing out, now its fine. select emp_id,emp_name,emp_cnic from employee_view a where a.emp_id in ( select distinct emp_id from hml_emp_attend_register where month_id = :p_month ) and ( (:p_cnic = 'YES' and emp_cnic is not null) or ( :p_cnic = 'NO' and emp_cnic is null) or (:p_cnic is null and (emp_cnic is not null or emp_cnic is null)) )
Hi, [Muhammad Masoom Ansari](/ords/forums/user/Muhammad Masoom Ansari) There's no point in saying or (:p_cnic is null and (emp_cnic is not null or emp_cnic is null)) Simply say
or (:p_cnic is null)
instead.
Hi @frank-kulash Yes, correct working suggested by you. Thank you.