Met*_*aft 3 oracle parameters in-clause
我对Oracle非常不熟悉,只是想使它起作用。我看过这里和这里,但不知道如何使它们全部正常工作。这就是我所需要的。我需要一个proc,它将以逗号分隔的字符串作为参数,我可以在查询的“ IN子句”中使用它并返回游标结果。这是在一个全包过程中做到这一点的方法吗?如果没有,我需要采取什么不同的步骤?再次,我对缺乏Oracle知识深表歉意,这只是想使某些东西真正快速地工作。
谢谢
这是proc(p_Scope将是逗号分隔的输入):
create or replace PROCEDURE CU_SELECTION_ID
(
p_Scope IN varchar2,
p_ResultSet OUT SYS_REFCURSOR
)
is
BEGIN
OPEN p_ResultSet FOR
select
b.addr1,
b.addr2,
b.city,
b.country_code,
a.customer_no,
b.des1,
a.entity,
b.main_phone_no,
b.phone_area_code,
b.status,
b.wb_site_url,
b.zip
from
ar_customer a,
ct_addr b
where b.main_loc_flag = 'Y' and
a.customer_no = b.customer_no and
a.entity = b.cust_entity and
b.stk_loc_no = '3' and
b.customer_no in (p_Scope);
END;
Run Code Online (Sandbox Code Playgroud)
我相信这是一种“更好的方式”,但我不确定现在的状况是什么...
不过,这应该对您有用:
更换:
b.customer_no in (p_Scope);
Run Code Online (Sandbox Code Playgroud)
与
instr(p_Scope, ','||b.customer_no||',' ) > 0
Run Code Online (Sandbox Code Playgroud)
如果b.customer_no出现在列表中,它将搜索p_Scope并返回> 0的值。
确保列表中的第一个和最后一个字符是逗号(',')
(此外,作为Oracle的新手,我发现Tech Republic是非常有用的快速资源。)
| 归档时间: |
|
| 查看次数: |
14742 次 |
| 最近记录: |