我是编程Oracle SQL的新手。可以使用参数在Oracle存储过程中使用以下sql(请参阅我要使用参数的位置)?如果是这样,怎么样?
Select Tuo.*
From OFFVISITS Tuo
inner join (
select mr1.pat_id, count(mr1.contact_date)
from OFFVISITS mr1
inner join (
select pat_id,count(contact_date)
from OFFVISITS
Where Death_Date Is Null
A nd Rpt_Grp = <parameter 1>
AND MONTHS_BETWEEN(SYSDATE,CONTACT_DATE) <= <parameter 2>
group by pat_id
having count(contact_date) >= <parameter 3>) mr2 on mr2.pat_id = mr1.pat_id
Where Mr1.Death_Date Is Null
And Mr1.Rpt_Grp = <parameter 4>
AND MONTHS_BETWEEN(SYSDATE,mr1.CONTACT_DATE) <= <parameter 5>
and mr1.ref_bill_code in (select DIAGNOSIS_CODE from DIAG_CODES)
group by mr1.pat_id
Having Count(Mr1.Contact_Date) >= 1) Mr On Mr.Pat_Id = Tuo.Pat_Id
AND TUO.RPT_GRP = <parameter 6>
order by tuo.pat_id';
感谢。
答案 0 :(得分:1)
是的,你可以。试试这个
CREATE OR REPLACE PROCEDURE MyFirst_PROC
(
PARAMETER_1_ IN VARCHAR2,
PARAMETER_4_ IN INT,
PARAMETER_5_ IN DATE
)
IS
BEGIN
...
Where Mr1.Death_Date Is Null
And Mr1.Rpt_Grp = PARAMETER_4_
AND MONTHS_BETWEEN(SYSDATE,mr1.CONTACT_DATE) <= PARAMETER_5_
END;
我已经剩下剩下的参数来填充和更正参数类型,因为我必须猜测你的列的类型(例如,Mr1.Rpt_Grp)