Oracle Variable Not Bound - ORA-01008

时间:2013-11-18 11:38:50

标签: database oracle plsql syntax-error

我一直在环顾四周,似乎无法想出这一点,我已经在堆栈上看了几个类似的问题,但仍然卡住了。当我尝试运行下面的块时,我收到ORA-01008: not all vaiables bound消息。

DECLARE
     io_TarId0   rates.r_id%TYPE := 0;
     io_TarId1   rates.r_id%TYPE := 0;
     io_TarId2   rates.r_id%TYPE := 0;
     io_TarId3   rates.r_id%TYPE := 0;
     oi_Result   PLS_INTEGER := 0;
     on_ErrID    system_errors.sys_err_id%TYPE := '-99999999999999';
BEGIN
     PKG.rates(:io_TarId0, '3791', '24', '6', '', '123', '', TO_DATE('18/11/2013', 'DD/MM/YYYY'), TO_DATE('', 'DD/MM/YYYY'), '', 0, :oi_Result, :on_ErrID);
     PKG.rates(:io_TarId1, '3791', '24', '4', '', '123', '', TO_DATE('18/11/2013', 'DD/MM/YYYY'), TO_DATE('', 'DD/MM/YYYY'), '', 0, :oi_Result, :on_ErrID);
     PKG.rates(:io_TarId2, '3791', '24', '5', '', '123', '', TO_DATE('18/11/2013', 'DD/MM/YYYY'), TO_DATE('', 'DD/MM/YYYY'), '', 0, :oi_Result, :on_ErrID);
     PKG.rates(:io_TarId3, '3791', '24', '3', '', '123', '', TO_DATE('18/11/2013', 'DD/MM/YYYY'), TO_DATE('', 'DD/MM/YYYY'), '', 1, :oi_Result, :on_ErrID);
END;

1 个答案:

答案 0 :(得分:3)

错误消息非常清楚 - 您的查询使用绑定变量,但您没有声明它们。

由于显然你想使用局部变量,只需摆脱':':

DECLARE
     io_TarId0   rates.r_id%TYPE := 0;
     io_TarId1   rates.r_id%TYPE := 0;
     io_TarId2   rates.r_id%TYPE := 0;
     io_TarId3   rates.r_id%TYPE := 0;
     oi_Result   PLS_INTEGER := 0;
     on_ErrID    system_errors.sys_err_id%TYPE := '-99999999999999';
BEGIN
     PKG.rates(io_TarId0, '3791', '24', '6', '', '123', '', TO_DATE('18/11/2013', 'DD/MM/YYYY'), TO_DATE('', 'DD/MM/YYYY'), '', 0, oi_Result, on_ErrID);
     PKG.rates(io_TarId1, '3791', '24', '4', '', '123', '', TO_DATE('18/11/2013', 'DD/MM/YYYY'), TO_DATE('', 'DD/MM/YYYY'), '', 0, oi_Result, on_ErrID);
     PKG.rates(io_TarId2, '3791', '24', '5', '', '123', '', TO_DATE('18/11/2013', 'DD/MM/YYYY'), TO_DATE('', 'DD/MM/YYYY'), '', 0, oi_Result, on_ErrID);
     PKG.rates(io_TarId3, '3791', '24', '3', '', '123', '', TO_DATE('18/11/2013', 'DD/MM/YYYY'), TO_DATE('', 'DD/MM/YYYY'), '', 1, oi_Result, on_ErrID);
END;