Hi have below SP which is running fine for the single value for example PARMPROFILES=wervbcjjlj
create or replace procedure OneView_Rpt_Get_Profile(PARMPROFILES varchar2,
out_curResults OUT sys_refcursor) is
begin
OPEN out_curResults FOR
select
upper(concat(concat(first_name, ' '), last_name)) User_Name,
ul.user_id as User_ID,
ul.Email_Id as EmailAddress,
p.profile_name as profilename,
upper(concat(concat(PW.OWNER_FIRST_NAME, ' '), PW.OWNER_LAST_NAME)) as OwnerName,
PU.ADDED_DATE
from User_List UL
join Profile_User PU on UL.USER_KEY = PU.USER_KEY
join Profile_Owner PW on PW.PROFILE_KEY = PU.PROFILE_KEY and PW.ACTIVE='Y'
join Profile p on p.profile_key= pu.profile_key
where 1=1
AND UL.GU_ID IS NOT NULL
and ul.active_flag = 'Y'
and p.profile_name in (PARMPROFILES );
end OneView_Rpt_Get_Profile;
but i want to pass multiple values in PARMPROFILES. where i run only simple query with multiple value its run fine
select
upper(concat(concat(first_name, ' '), last_name)) User_Name,
ul.user_id as User_ID,
ul.Email_Id as EmailAddress,
p.profile_name as profilename,
upper(concat(concat(PW.OWNER_FIRST_NAME, ' '), PW.OWNER_LAST_NAME)) as OwnerName,
PU.ADDED_DATE
from User_List UL
join Profile_User PU on UL.USER_KEY = PU.USER_KEY
join Profile_Owner PW on PW.PROFILE_KEY = PU.PROFILE_KEY and PW.ACTIVE='Y'
join Profile p on p.profile_key= pu.profile_key
where 1=1
AND UL.GU_ID IS NOT NULL
and ul.active_flag = 'Y'
and p.profile_name in ('wervbcjjlj','test_shub_prt' )
Not sure how to pass multiple value in SP. Please Advice !!
One option is to split entered comma-separated values into rows (lines #9 - 11) and use it as a subquery.
This is an example with a function (for simplicity):
SQL> create or replace function f_test (par_in in varchar2)
2 return sys_refcursor
3 is
4 l_rc sys_refcursor;
5 begin
6 open l_rc for
7 select empno, ename, job, sal
8 from emp
9 where job in (select regexp_substr(par_in, '[^,]+', 1, level)
10 from dual
11 connect by level <= regexp_count(par_in, ',') + 1
12 );
13 return l_rc;
14 end;
15 /
Function created.
SQL> select f_test('MANAGER,CLERK') from dual;
F_TEST('MANAGER,CLER
--------------------
CURSOR STATEMENT : 1
CURSOR STATEMENT : 1
EMPNO ENAME JOB SAL
---------- ---------- --------- ----------
7369 SMITH CLERK 1000
7566 JONES MANAGER 2975
7698 BLAKE MANAGER 2850
7782 CLARK MANAGER 2450
7876 ADAMS CLERK 1100
7900 JAMES CLERK 950
7934 MILLER CLERK 1300
7 rows selected.
SQL>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.