【发布时间】:2017-02-25 10:49:47
【问题描述】:
我的程序在执行时出现以下错误:
Error starting at line : 1 in command -
exec p_matrika(2010,2.5,'26311330')
Error report -
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'P_MATRIKA'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
程序编译没有错误。我还检查了 SQL 语句,它按原样工作,返回 1 行,所以一定是我在程序本身做错了什么。对于 SQL 语句的格式有点混乱,我深表歉意。当我复制和粘贴它时,它不知何故搞砸了。
create or replace PROCEDURE P_MATRIKA
(
leto IN NUMBER,
rating IN NUMBER,
davcna IN VARCHAR2,
unsec_out OUT NUMBER,
supp_out OUT NUMBER,
sec_out OUT NUMBER,
unsec_limit OUT NUMBER,
supp_limit OUT NUMBER,
sec_limit OUT NUMBER,
unsec_tenor OUT NUMBER,
supp_tenor OUT NUMBER,
sec_tenor OUT NUMBER
)
AS
out_unsec NUMBER;
out_supp NUMBER;
out_sec NUMBER;
limit_unsec NUMBER;
limit_supp NUMBER;
limit_sec NUMBER;
tenor_unsec NUMBER;
tenor_supp NUMBER;
tenor_sec NUMBER;
BEGIN
with
matrika_osnova
as
(
select distinct a.par_davcna, nvl(a.unsecured,0) unsec_out,
nvl(a.supported,0) supp_out, nvl(a.secured,0) sec_out,
x.tip_sub, x.cispri, x.kraban, x.dolfinobv,
y.ltv_tip, y.rating, y.unsec_pct, q.supp_pct,
w.sec_pct, p.unsec_maxznes, s.sec_maxznes,
case when y.unsec_pct * nvl(x.cispri,0) > nvl(p.unsec_maxznes,0) then
nvl(p.unsec_maxznes,0) - nvl(x.kraban,0) + (nvl(x.dolfinobv,0)/5)
else
case when y.unsec_pct * nvl(x.cispri,0) -
nvl(x.kraban,0) + (nvl(x.dolfinobv,0)/5) < 0 then
0
else
y.unsec_pct * nvl(x.cispri,0) - nvl(x.kraban,0) +
(nvl(x.dolfinobv,0)/5)
end
end unsec_max,
case when q.supp_pct * nvl(x.cispri,0) > nvl(s.sec_maxznes,0) then
nvl(s.sec_maxznes,0) - nvl(x.kraban,0) + (nvl(x.dolfinobv,0)/5)
else
case when q.supp_pct * nvl(x.cispri,0) - nvl(x.kraban,0) +
(nvl(x.dolfinobv,0)/5) < 0 then
0
else
q.supp_pct * nvl(x.cispri,0) - nvl(x.kraban,0) +
(nvl(x.dolfinobv,0)/5)
end
end supp_max,
case when w.sec_pct * nvl(x.cispri,0) > nvl(s.sec_maxznes,0) then
nvl(s.sec_maxznes,0) - nvl(x.kraban,0) + (nvl(x.dolfinobv,0)/5)
else
case when w.sec_pct * nvl(x.cispri,0) - nvl(x.kraban,0) +
(nvl(x.dolfinobv,0)/5) < 0 then
0
else
w.sec_pct * nvl(x.cispri,0) - nvl(x.kraban,0) +
(nvl(x.dolfinobv,0)/5)
end
end sec_max,
d.unsec_tenor, e.supp_tenor, f.sec_tenor
from sco_matrika_banka a
inner join
(select b.tip_sub, b.par_davcna, b.cispri, b.kraban, b.dolfinobv
from scoring_gvin b
where b.leto = leto) x --IN parameter
on a.par_davcna = x.par_davcna
inner join
(select a.tip_sub, a.ltv_tip,
a.max_znesek unsec_maxznes
from sco_sif_ltv_maxznes a
where a.ltv_tip = 1) p
on x.tip_sub = p.tip_sub
inner join
(select a.tip_sub, a.ltv_tip,
a.max_znesek sec_maxznes
from sco_sif_ltv_maxznes a
where a.ltv_tip = 3) s
on x.tip_sub = s.tip_sub
inner join
(select a.tip_sub, a.ltv_tip,
a.rating, a.ltv_pct unsec_pct
from sco_sif_ltv_pct a
where a.ltv_tip = 1
and a.rating = rating) y --IN parameter
on x.tip_sub = y.tip_sub
inner join
(select a.tip_sub, a.ltv_tip,
a.rating, a.ltv_pct supp_pct
from sco_sif_ltv_pct a
where a.ltv_tip = 2
and a.rating = rating) q --IN parameter
on x.tip_sub = y.tip_sub
inner join
(select a.tip_sub, a.ltv_tip,
a.rating, a.ltv_pct sec_pct
from sco_sif_ltv_pct a
where a.ltv_tip = 3
and a.rating = rating) w --IN parameter
on x.tip_sub = y.tip_sub
inner join
(select a.tip_sub, a.tenor unsec_tenor
from sco_sif_ltv_tenor a
where a.ltv_tip = 1) d
on x.tip_sub = d.tip_sub
inner join
(select a.tip_sub, a.tenor supp_tenor
from sco_sif_ltv_tenor a
where a.ltv_tip = 2) e
on x.tip_sub = e.tip_sub
inner join
(select a.tip_sub, a.tenor sec_tenor
from sco_sif_ltv_tenor a
where a.ltv_tip = 3) f
on x.tip_sub = f.tip_sub
where a.par_davcna = davcna) --IN parameter
select a.unsec_out, a.supp_out, a.sec_out,
case when a.unsec_max - a.unsec_out < 0 then
0
else
a.unsec_max - a.unsec_out
end unsec_limit,
case when a.supp_max - a.supp_out < 0 then
0
else
a.supp_max - a.supp_out
end supp_limit,
case when a.sec_max - a.sec_out < 0 then
0
else
a.sec_max - a.sec_out
end sec_limit,
a.unsec_tenor, a.supp_tenor, a.sec_tenor
into
out_unsec, out_supp, out_sec, limit_unsec, limit_supp,
limit_sec, tenor_unsec, tenor_supp, tenor_sec
from matrika_osnova a;
unsec_out := out_unsec;
supp_out := out_supp;
sec_out := out_sec;
unsec_limit := limit_unsec;
supp_limit := limit_supp;
sec_limit := limit_sec;
unsec_tenor := tenor_unsec;
supp_tenor := tenor_supp;
sec_tenor := tenor_sec;
END P_MATRIKA;
【问题讨论】:
-
您的过程有 12 个参数,而您只传递了 3 个。您希望 OUT 值去哪里?
-
@AlexPoole 感谢您的快速回复。我对 PL/SQL 很陌生。我的目标是获得指定 9 个 OUT 参数的行。
-
您的过程有多个标量输出参数,您根本不会得到“行”。您打算如何处理通话结果;你将如何使用这些值?您的过程中的查询实际上会返回多少行——总是正好是一个? (不知道你为什么在这里使用一个过程,而不是直接运行查询。)
-
它假设将值返回到我的 C# 应用程序。是的,总是正好 1 行。我可以使用内联 SQL,但这样每次运行时 SQL 都必须编译,而存储过程只编译一次。
-
这是不正确的。如果不在缓存中,则对 SQL 进行硬解析,如果在缓存中,则进行更快的软解析。该过程的 PL/SQL 编译一次,它调用的 SQL 被视为直接调用,并且仍将获得软解析。不过,出于其他原因(例如可维护性等),您可能仍希望在程序中使用它。