oracle 存储过程1

基本结构

CREATE OR REPLACEPROCEDURE 存储过程名字
(
    参数1 IN NUMBER,
    参数2 IN NUMBER
) IS
变量1 INTEGER :=0;
变量2 DATE;
BEGIN
END 存储过程名字

 

---查询数据 并返回一个列表

DROP PROCEDURE MRR.get_risk_assessment_by_status;

CREATE OR REPLACE PROCEDURE MRR.get_risk_assessment_by_status (
    out_ref_cursor OUT SYS_REFCURSOR,
    stas IN VARCHAR2
) IS
BEGIN
    OPEN out_ref_cursor FOR
         SELECT RA.riskassessment_id as RA_RISKASSESSMENT_ID, RA.riskconfig_id as RA_RISKCONFIG_ID, RA.assessment_status as RA_ASSESSMENT_STATUS, RA.changed_numeric_rating_id as RA_CHANGED_NUMERIC_RATING_ID, RA.changed_alpha_rating_id as RA_CHANGED_ALPHA_RATING_ID, RA.due_date as RA_DUE_DATE, RA.initial_assessment_complete as RA_INITIAL_ASSESSMENT_COMPLETE, RA.initial_numeric_rating_id as RA_INITIAL_NUMERIC_RATING_ID, RA.initial_alpha_rating_id as RA_INITIAL_ALPHA_RATING_ID, RA.notes as RA_NOTES, RA.prior_riskassessment_id as RA_PRIOR_RISKASSESSMENT_ID, RA.risk_mgmt_approval_date as RA_RISK_MGMT_APPROVAL_DATE, RA.risk_mgmt_approval_emp_id as RA_RISK_MGMT_APPROVAL_EMP_ID, RA.last_updated_by as RA_LAST_UPDATED_BY, RA.last_updated as RA_LAST_UPDATED,
                RC.riskconfig_id as RC_RISKCONFIG_ID, RC.riskcategorygroup_id as RC_RISKCATEGORYGROUP_ID, RC.contractentity_id as RC_CONTRACTENTITY_ID, RC.accountgroup_id as RC_ACCOUNTGROUP_ID, RC.account_id as RC_ACCOUNT_ID, RC.contract_id as RC_CONTRACT_ID, RC.next_assessment_due_date as RC_NEXT_ASSESSMENT_DUE_DATE, RC.ninety_day_assessment_complete as RC_NINETY_DAY_ASSESS_COMPLE, RC.inactive_date as RC_INACTIVE_DATE, RC.last_updated_by as RC_LAST_UPDATED_BY, RC.last_updated as RC_LAST_UPDATED
          FROM MRR.riskassessment RA, MRR.riskconfig RC
          WHERE RA.riskconfig_id = RC.riskconfig_id
          AND RA.assessment_status = stas;
END;
/

GRANT EXECUTE ON MRR.get_risk_assessment_by_status TO DMM_KCMRLRSK_ROLE;
/

 

参考博客:http://www.eygle.com/digest/2008/05/java_oracle_procedure.html

你可能感兴趣的:(oracle,存储过程,职场,休闲)