我正在学习mysql,并已转移到程序。我创建了一个程序,我正在尝试运行它。但是当我运行程序时,我面临很多错误,错误指向没有错误的行,我可以看到,有人可以帮助我吗?
这是我创建的程序
create or replace PROCEDURE AD_AGENCY_INFO(
v_ad_id IN ad_agency.AGENCY_ID%TYPE,
v_cert IN ad_agency.NO_OF_AD_RUNS%TYPE,
v_price IN ad_agency.CREDIT_WORTHY%TYPE,
v_agency_id IN ad_agency.AGENCY_ID%TYPE
) AS
BEGIN
UPDATE AD SET AD_ID = v_ad_id, CERTIFICTAION = v_cert, PRICE = v_price where agency_id = v_agency_id;
INSERT INTO AD_SLOT (AD_ID) VALUES (v_ad_id);
EXCEPTION
WHEN NO_DATA_FOUND THEN
rollback;
END AD_AGENCY_INFO;
这就是我调用程序的方法
DECLARE
V_AGENCY_ID NUMBER:=&Enter_Agency_ID;
V_NO_OF_RUNS NUMBER:=&Enter_No_of_Runs;
V_CREDIT_WORTHY CHAR(3):=&Enter_Credit_Worthy;
V_AVAILABLE_SLOTS NUMBER:=&Enter_Available_Slots;
V_STATUS CHAR(1):=&Enter_Status;
BEGIN
V_AGENCY_ID := NULL;
V_NO_OF_RUNS := NULL;
V_CREDIT_WORTHY := NULL;
V_AVAILABLE_SLOTS := NULL;
V_STATUS := NULL;
AD_AGENCY_INFO(
V_AGENCY_ID => V_AGENCY_ID,
V_NO_OF_RUNS => V_NO_OF_RUNS,
V_CREDIT_WORTHY => V_CREDIT_WORTHY,
V_AVAILABLE_SLOTS => V_AVAILABLE_SLOTS,
V_STATUS => V_STATUS
);
END;
这是我在运行程序后得到的错误日志
Error report -
ORA-06550: line 4, column 28:
PLS-00201: identifier 'N' must be declared
ORA-06550: line 4, column 19:
PL/SQL: Item ignored
ORA-06550: line 6, column 21:
PLS-00201: identifier 'Y' must be declared
ORA-06550: line 6, column 12:
PL/SQL: Item ignored
ORA-06550: line 10, column 3:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 10, column 3:
PL/SQL: Statement ignored
ORA-06550: line 12, column 3:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 12, column 3:
PL/SQL: Statement ignored
ORA-06550: line 17, column 24:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
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:
答案 0 :(得分:0)
在您用于调用过程的脚本中,您正在使用替换变量。在解释脚本之前,它们将被其值替换。这意味着像V_CREDIT_WORTHY CHAR(3):=&Enter_Credit_Worthy;
这样的值为“no”的行将被翻译为V_CREDIT_WORTHY CHAR(3):=no;
您会注意到“no”在那里没有引用。为了使用替换变量将字符串传递给PL / SQL脚本,您需要将绑定变量括在引号中:V_CREDIT_WORTHY CHAR(3):='&Enter_Credit_Worthy';
。
另一种方法是使用绑定变量。它们被解释为脚本的一部分,因此可以被视为普通变量。要做到这一点,您只需要用冒号替换&符号。我上面提到的这一行将成为V_CREDIT_WORTHY CHAR(3):=:Enter_Credit_Worthy;
。