我有以下步骤,应该删除特定的客户。我不断收到错误,我不确定为什么。我是新来的,这是课堂作业。
在此先感谢您的帮助:
CREATE or REPLACE PROCEDURE DISP_CUST_DELETE (I_CUSTOMER_NUM IN CUSTOMER_NUM&TYPE)
BEGIN
DELETE
FROM CUSTOMER
WHERE CUSTOMER_NUM = I_CUSTOMER_NUM;
dbms_output.put_line('Customer has been deleted');
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('NO CUSTOMER WITH this number has been deleted');
END;
/
这里有一些更新。
是的,对不起,这就是我的意思。这是更新的过程。
CREATE or REPLACE PROCEDURE DISP_CUST_DELETE (I_CUSTOMER_NUM IN CUSTOMER.CUSTOMER_NUM) AS
BEGIN
DELETE
FROM CUSTOMER
WHERE CUSTOMER_NUM = I_CUSTOMER_NUM;
dbms_output.put_line('Customer' || I_CUSTOMER_NUM ||'has been deleted');
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('NO CUSTOMER WITH'||I_CUSTOMER_NUM||'has been deleted');
END;
/
这是我得到的错误:
0/0 PL / SQL:编译单元分析已终止1/47
PLS-00488:“ CUSTOMER.CUSTOMER_NUM”必须为类型
答案 0 :(得分:0)
就像注释中建议的@sticky bit
一样,您的代码有语法错误。
为了使您将变量声明为与先前声明的变量或表的列相同的类型,应使用table.table_column%TYPE
。
CREATE or REPLACE PROCEDURE DISP_CUST_DELETE (
I_CUSTOMER_NUM IN CUSTOMER.CUSTOMER_NUM%TYPE --> This line here
) AS
BEGIN
DELETE
FROM CUSTOMER
WHERE CUSTOMER_NUM = I_CUSTOMER_NUM;
dbms_output.put_line('Customer' || I_CUSTOMER_NUM ||'has been deleted');
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('NO CUSTOMER WITH'||I_CUSTOMER_NUM||'has been deleted');
END;
/