2

我对 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';

谢谢。

4

1 回答 1

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)是什么类型

于 2012-11-25T20:41:27.957 回答