-2

我是否以正确的方式处理以下过程,有一些编译错误,有人可以帮我解决我所做的错误。

create or replace PROCEDURE CRangeproc(in_termid IN VARCHAR2,in_cardno IN VARCHAR2,outcount OUT NUMBER,outissu OUT VARCHAR2,outacq OUT VARCHAR2,CIssuer OUT SYS_REFCURSOR,CAcquirer OUT SYS_REFCURSOR)
AS
BEGIN
select count(*) into outcount from cardrangetable where PAN_LOW <= in_cardno AND  PAN_HIGH >=  in_cardno and terminal_id = in_termid;
if outCount = 1 then
select ISSUERTABLEID into outissu,ACQUIRERTABLEID into outacq from cardrangetable where PAN_LOW <= in_cardno AND  PAN_HIGH >= in_cardno and terminal_id = in_termid;
Open CIssuer FOR
select * from Issuer_tble where TERMINAL_ID = in_termid and ISSUERTABLEID = outissu;
CLOSE CIssuer;
Open CAcquirer FOR
select * from ACQUIRERTABLE where TERMINAL_ID = in_termid and ACQUIRERID = outacq;
CLOSE CAcquirer;
end if;
End CRangeproc;

谢谢

4

2 回答 2

0

嗨,在这部分我看到一些错误

 if Outcount = 1 then
select Issuertableid
  into Outissu, Acquirertableid
  into Outacq 
 from Cardrangetable
 where Pan_Low <= In_Cardno
   and Pan_High >= In_Cardno
   and Terminal_Id = In_Termid;

应该是这样的

 if Outcount = 1 then
select Issuertableid,  Acquirertableid
  into Outissu, Outacq
 from Cardrangetable
 where Pan_Low <= In_Cardno
   and Pan_High >= In_Cardno
   and Terminal_Id = In_Termid;

和打开/关闭错误使用(也许你正在尝试使用游标)

 open Cissuer for
   ------
close Cissuer;
open Cacquirer for
     ----
close Cacquirer;
于 2012-11-01T11:36:36.217 回答
0

这是每个 SELECT 语句的一个子句 INTO。您不应关闭此函数中的 REF CURSOR。消耗它们的程序需要处理它们。

这就是您的代码应该的样子:

create or replace PROCEDURE CRangeproc
    (in_termid IN VARCHAR2
    ,in_cardno IN VARCHAR2
    ,outcount OUT NUMBER
    ,outissu OUT VARCHAR2
    ,outacq OUT VARCHAR2
    ,CIssuer OUT SYS_REFCURSOR
    ,CAcquirer OUT SYS_REFCURSOR)
AS
BEGIN
    select count(*) 
    into outcount 
      from cardrangetable 
    where PAN_LOW <= in_cardno 
    AND  PAN_HIGH >=  in_cardno 
    and terminal_id = in_termid;

    if outCount = 1 then
        select ISSUERTABLEID,ACQUIRERTABLEID 
        into outissu, outacq 
                from cardrangetable 
        where PAN_LOW <= in_cardno 
        AND  PAN_HIGH >= in_cardno 
        and terminal_id = in_termid;
        Open CIssuer FOR
            select * from Issuer_tble 
                          where TERMINAL_ID = in_termid 
                          and ISSUERTABLEID = outissu;
        Open CAcquirer FOR
            select * from ACQUIRERTABLE 
                          where TERMINAL_ID = in_termid 
                          and ACQUIRERID = outacq;
    end if;
End CRangeproc;

我认为您需要学习使用回车来改进代码的布局。

于 2012-11-01T12:44:06.913 回答