LIKE with varying number of values
From: Dereck <dietzdl_at_ameritech.net>
Date: Sun, 19 Jul 2009 12:08:21 -0700 (PDT)
Message-ID: <5add2f84-f4ce-4462-b2b0-a92db658782f_at_k6g2000yqn.googlegroups.com>
Oracle 10.2.0.3.0
Windows 2003 Server
Date: Sun, 19 Jul 2009 12:08:21 -0700 (PDT)
Message-ID: <5add2f84-f4ce-4462-b2b0-a92db658782f_at_k6g2000yqn.googlegroups.com>
Oracle 10.2.0.3.0
Windows 2003 Server
I have a cursor defined as follows which I can use in a number of different procedures:
CURSOR cr_cursor( p_start_date IN DATE,
p_end_date IN DATE,
p_tab IN t_cpt_hcpcs_tab,
p_service IN tmp$_measures.service_type_code
%TYPE )
RETURN tmp$_measures$ROWTYPE
IS
SELECT C_ADMIN_DATA,
NULL,
NULL,
SUBSTR(mbr_key,1,27),
mbr_sys_key,
person_id,
TRUNC(srv_dt_from),
p_service
FROM v_claim
WHERE srv_dt_from BETWEEN p_start_date AND p_end_date
AND person_id > 0
AND cpt_hcpcs IN ( SELECT column_value FROM TABLE(p_tab) )
UNION ALL
SELECT C_STATE_HISTORICAL_CLAIM,
NULL,
NULL,
SUBSTR(mbr_key,1,27),
mbr_sys_key,
person_id,
TRUNC(srv_dt_from),
p_service
FROM v_claim_external
WHERE srv_dt_from BETWEEN p_start_date AND p_end_date
AND person_id > 0
AND cpt_hcpcs IN ( SELECT column_value FROM TABLE(p_tab) );
I would like to figure out a way where I could convert the cursor
below to where I can
reuse it from different procedures using a varying number of procedure
codes similar to
how the above cursor works. The only problem is that if I try the
same syntax as above
I get a too many values retrieved error from using the LIKE.
CURSOR cr_cursor( p_start_date IN DATE,
p_end_date IN DATE )
RETURN tmp$_measures%ROWTYPE
IS
SELECT C_ADMIN_DATA,
NULL,
NULL,
SUBSTR(mbr_key,1,27),
mbr_sys_key,
person_id,
TRUNC(srv_dt_from),
C_DIPTHERIA
FROM v_claim
WHERE srv_dt_from BETWEEN p_start_date AND p_end_date
AND person_id > 0
AND (
proc_i_1 LIKE '9936%'
OR proc_i_1 LIKE '9939%'
)
UNION ALL
SELECT C_STATE_HISTORICAL_CLAIM,
NULL,
NULL,
SUBSTR(mbr_key,1,27),
mbr_sys_key,
person_id,
TRUNC(srv_dt_from),
C_DIPTHERIA
FROM v_claim_external
WHERE srv_dt_from BETWEEN p_start_date AND p_end_date
AND person_id > 0
AND (
proc_i_1 LIKE '9936%'
OR proc_i_1 LIKE '9939%'
);
IS there a way where I can use the LIKE clause with a varying number of values?
Thanks Received on Sun Jul 19 2009 - 14:08:21 CDT
