PL/SQL (MOSC)

MOSC Banner

case in where clause

edited Nov 14, 2012 9:51PM in PL/SQL (MOSC) 3 commentsAnswered ✓
hi,
i have a requirement that i need to fetch data from db based on the where condition


create or replace procedure xxtest(p_flag in number,p_job in varchar2) is
cursor c is select * from scott.emp where 1=1 and case when p_flag=1 then
                                                                                                       job=p_job
                                                                                                      else
                                                                                                       job not in(p_job)
                                                                                                     end ;
begin
for i in c loop
dbms_output.put_line(i.empno||i.ename);
end loop;
end;


i am facing the sysntax error and i am not sure is it works or not

my requirement is if p_flag =1 then it has to display the p_job details

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center