使用SYS_REFCURSOR OUT调用过程

时间:2014-09-16 06:20:47

标签: oracle plsql cursor toad

我的数据库中有以下过程,编译没有任何错误:

create or replace procedure itcustadm.TEST_PROC_AJCP_1
(
    sldr_indate   in date,
    r18_refcursor out sys_refcursor
)
as begin

open r18_refcursor for

select
    gthv.bank_id,
    gthv.sol_id,
    gthv.gl_sub_head_code GLSH_Code,
    decode(gthv.gl_sub_head_code,
        '10301',1,
        '10403',2, '60403',2, '10501',2, '60501',2, '10502',2,
        '10503',2, '10504',2, '10505',2, '10507',2, '10509',2,
        '60509',2, '10511',2, '10518',2, '60518',2, '10523',2,
        '60523',2, '10551',2, '10552',2, '10553',2, '10554',2,
        '10555',2, '10557',2, '10559',2, '10561',2, '10568',2,
        '10573',2,
        '12336',3, '62336',3, '10401',3, '60402',3, 4 ) GLSH_SET, 
    case
        when (cast(substr(gthv.gl_sub_head_code,0,1) as int) >= 1
            and cast(substr(gthv.gl_sub_head_code,0,1) as int) <= 5)
        then 'R'
        when cast(substr(gthv.gl_sub_head_code,0,1) as int) = 0
            or (cast(substr(gthv.gl_sub_head_code,0,1) as int) >= 6
            and cast(substr(gthv.gl_sub_head_code,0,1) as int) <= 9)
        then 'F'
    end book_type,
    gthv.tran_crncy_code Tran_Currency,
    gthv.value_date,
    gthv.tran_date Transaction_Date,
    gthv.gl_date,
    gthv.tran_particular,
    trim(gthv.tran_id) Transaction_ID,
    gthv.dth_init_sol_id Posting_SOL,
    gthv.tran_rmks Tran_Remarks,
    case
        when (gthv.part_tran_type = 'D')
        then (gthv.tran_amt)
    end dr_amount,
    case
        when (gthv.part_tran_type = 'C')
        then (gthv.tran_amt)
    end cr_amount,
    gsh.gl_sub_head_desc GLSH_Name,
    gam.foracid account_number,
    gam.acct_name,
    case when
       (select tran_date_bal from tbaadm.eab
           where eab.eod_date = (select max(eab.eod_date) from tbaadm.eab
               where gthv.bank_id = eab.bank_id and gthv.acid = eab.acid and eab.eod_date < '4-NOV-2013')
           and gthv.acid = eab.acid
           and gthv.bank_id = eab.bank_id) is not null
       then (select tran_date_bal from tbaadm.eab
           where eab.eod_date = (select max(eab.eod_date) from tbaadm.eab
               where gthv.bank_id = eab.bank_id and gthv.acid = eab.acid and eab.eod_date < '4-NOV-2013')
           and gthv.acid = eab.acid
           and gthv.bank_id = eab.bank_id)
       else 0
    end beg_tran_date_bal,
    (select tran_date_bal from tbaadm.eab eab
        where eod_date = (select max(eab.eod_date) from tbaadm.eab eab
            where gthv.bank_id = eab.bank_id and gthv.acid = eab.acid and eab.eod_date <= '4-NOV-2013')
        and gthv.acid = eab.acid
        and gthv.bank_id = eab.bank_id) end_tran_date_bal,
    (select ent.bank_desc from crmuser.entity_details ent
        where gam.bank_id = ent.bank_id) bank_description,
    (select crncy_alias_num from tbaadm.cnc where gam.bank_id = cnc.bank_id
        and cnc.crncy_code = gam.acct_crncy_code) currency_no,
    (select sol.sol_desc from tbaadm.sol where gthv.bank_id = sol.bank_id
        and gthv.sol_id = sol.sol_id) SOL_Description,
    ott.ref_num OAP_Ref_No,
    crp.pcc_code,
    crp.mop_id

from itcustadm.gl_tran_hist_view gthv
    left outer join tbaadm.gam
        on gthv.bank_id = gam.bank_id and gthv.acid = gam.acid
    left outer join tbaadm.gsh
        on gam.bank_id = gsh.bank_id and gam.sol_id = gsh.sol_id
        and gam.gl_sub_head_code = gsh.gl_sub_head_code
        and gam.acct_crncy_code = gsh.crncy_code
    left outer join tbaadm.ott
        on gthv.tran_id = ott.tran_id and gthv.tran_date = ott.tran_date
        and gthv.part_tran_srl_num = ott.part_tran_srl_num
        and gthv.bank_id = ott.bank_id and gthv.acid = ott.acid
    left outer join custom.c_REPRINT crp
        on gthv.bank_id = crp.bank_id and gthv.tran_date = crp.tran_date
        and trim(gthv.tran_id) = trim(crp.tran_id)

where
    gam.acct_ownership = 'O'
    and gthv.bank_id = 'CBC01'
    and gthv.gl_date = sldr_indate
    and (gam.gl_sub_head_code in ('10301','10403','60403',
        '10501','60501','10502','10503','10504','10505',
        '10507','10509','60509','10511','10518','60518',
        '10523','60523','10551','10552','10553','10554',
        '10555','10557','10559','10561','10568','10573',
        '12336','62336','10401','60402')
        or gam.acct_classification_flg in ('I','E')
        )
    and (trim(gthv.del_flg) != 'Y' or gthv.del_flg is null)
    and (trim(gam.del_flg) != 'Y' or gam.del_flg is null)
    and (trim(gsh.del_flg) != 'Y' or gsh.del_flg is null);
end;

我想要做的是以某种方式调用Toad中的过程,因为我想测试输入日期是否正在传递,输出将是我期待的那个。这是我到目前为止:

begin
    TEST_PROC_AJCP_1( '4-NOV-2013' :r18r );
end;

出现Variables弹出窗口,我将R18R的Type设置为Cursor,单击OK,出现错误:

RA-06550: line 2, column 36:
PLS-00103: Encountered the symbol "" when expecting one of the following:

   ) , * & = - + < / > at in is mod remainder not rem =>
   <an exponent (**)> <> or != or ~= >= <= <> and or like like2
   like4 likec as between from using || multiset member
   submultiset
The symbol "," was substituted for "" to continue.

如何使用Toad正确调用或执行某个程序?在此先感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您只是在通话中错过了两个参数参数之间的逗号:

begin
    TEST_PROC_AJCP_1( '4-NOV-2013', :r18r );
end;

您还应该将日期作为日期而不是字符串传递,以避免歧义,例如: to_date('4-NOV-2013', 'DD-MON-YYYY')date '2013-11-04'