SQl无效对象

时间:2014-11-26 16:43:22

标签: oracle plsql

我的程序遇到了一些麻烦,我认为代码正常运行,程序运行并要求用户输入,用户输入存储在程序中的变量中的数据,然后插入到表中。但是当我输入所有我面临错误的东西时。甚至可以在程序中使用插入物,还是应该走另一条路线?感谢

我的程序

  create or replace PROCEDURE AD_AGENCY_INFO(
v_agency_id IN OUT AD_AGENCY.AGENCY_ID%TYPE,
v_no_of_ad_runs IN OUT AD_AGENCY.NO_OF_AD_RUNS%TYPE,
v_credit_worthy IN OUT AD_AGENCY.CREDIT_WORTHY%TYPE,
v_available_slots IN OUT AD_AGENCY.AVAILABLE_SLOTS%TYPE,
v_status IN OUT AD_AGENCY.STATUS%TYPE
) AS
  BEGIN

SELECT AGENCY_ID, NO_OF_AD_RUNS, CREDIT_WORTHY, AVAILABLE_SLOTS, STATUS 
INTO 
v_agency_id, v_no_of_ad_runs, v_credit_worthy, v_available_slots, v_status 
FROM AD_AGENCY;

INSERT INTO AD_AGENCY (AGENCY_ID, NO_OF_AD_RUNS, CREDIT_WORTHY, AVAILABLE_SLOTS, STATUS) 
VALUES (AGENCY_ID, NO_OF_AD_RUNS, CREDIT_WORTHY, AVAILABLE_SLOTS, STATUS);
INSERT INTO AD (AGENCY_ID) VALUES (AGENCY_ID);


END AD_AGENCY_INFO;

我如何调用程序

DECLARE
 V_AGENCY_ID NUMBER:='&Enter_Agency_ID';
V_NO_OF_AD_RUNS NUMBER:='&Enter_No_of_Ad_Runs';
V_CREDIT_WORTHY CHAR(3):='&Enter_Cedit_Worthy';
  V_AVAILABLE_SLOTS NUMBER:='&Enter_Available_Slots';
V_STATUS CHAR(1):='&Enter_Status';
BEGIN
V_AGENCY_ID := NULL;
V_NO_OF_AD_RUNS := 0;
V_CREDIT_WORTHY := NULL;
V_AVAILABLE_SLOTS := NULL;
V_STATUS := NULL;

AD_AGENCY_INFO(
V_AGENCY_ID => V_AGENCY_ID,
V_NO_OF_AD_RUNS => V_NO_OF_AD_RUNS,
V_CREDIT_WORTHY => V_CREDIT_WORTHY,
V_AVAILABLE_SLOTS => V_AVAILABLE_SLOTS,
V_STATUS => V_STATUS
); 
END;
/

错误报告

Error report -
ORA-06550: line 14, column 3:
PLS-00905: object DT2113A.AD_AGENCY_INFO is invalid
ORA-06550: line 14, column 3:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

2 个答案:

答案 0 :(得分:0)

这里可能存在一些拼写错误:

INSERT INTO AD_AGENCY (AGENCY_ID, NO_OF_AD_RUNS, CREDIT_WORTHY, AVAILABLE_SLOTS, STATUS) 
VALUES (AGENCY_ID, NO_OF_AD_RUNS, CREDIT_WORTHY, AVAILABLE_SLOTS, STATUS);
--      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

值是......井值,而不是列名。也许你想:

INSERT INTO AD_AGENCY (AGENCY_ID, NO_OF_AD_RUNS, CREDIT_WORTHY, AVAILABLE_SLOTS, STATUS) 
VALUES (v_agency_id, v_no_of_ad_runs, v_credit_worthy, v_available, v_status);

顺便说一下,剩下的代码可能还需要一些想法;) 例如,只要表中有多行,该代码就不会起作用:

SELECT AGENCY_ID, NO_OF_AD_RUNS, CREDIT_WORTHY, AVAILABLE_SLOTS, STATUS 
INTO 
v_agency_id, v_no_of_ad_runs, v_credit_worthy, v_available_slots, v_status 
FROM AD_AGENCY;

可能缺少WHERE条款?即使如此,它也会覆盖IN参数值。可能不是你想要的东西......

答案 1 :(得分:0)

我不熟悉plsql,但似乎你错误地从第二个块调用了该过程。试着写:

CALL AD_AGENCY_INFO( 
... 
);

或者使用Exec,我不太确定哪个:

EXEC AD_AGENCY_INFO(
 ...
);