我創建了一個從三個表中刪除數據的過程,這些表都與外鍵鏈接,但不會運行。這裏是程序。刪除程序不會運行並給出錯誤?
PROCEDURE remove_customer (customer_id VARCHAR2) IS
BEGIN
DELETE FROM order_line
WHERE order_line.order_id = placed_order.order_id;
DELETE FROM placed_order
WHERE placed_order.customer_id = customer.customer_id;
DELETE FROM customer
WHERE customer.customer_id = remove_customer.customer_id;
total_customers := total_customers - 1;
END;
這裏是三個表格的結構。任何人知道我爲什麼會得到錯
customer(
Customer_ID INTEGER NOT NULL,
Country VARCHAR(15),
First_Name VARCHAR(30),
Last_Name VARCHAR(30),
CONSTRAINT pk_customer PRIMARY KEY (Customer_ID)
);
placed_order(
order_id INTEGER NOT NULL,
order_date VARCHAR(15),
fk1_Customer_ID INTEGER NOT NULL,
fk2_Employee_ID INTEGER NOT NULL,
fk3_order_type_id INTEGER NOT NULL,
CONSTRAINT pk_placed_order PRIMARY KEY (order_id)
);
order_line(
order_line_id INTEGER NOT NULL,
fk1_order_id INTEGER NOT NULL,
fk2_product_id INTEGER NOT NUL,
CONSTRAINT pk_order_line PRIMARY KEY (order_line_id)
);
這是兩個錯誤的迴歸。
ORA-00904: 「PLACED_ORDER」 「ORDER_ID」:無效identifierCompilation失敗,行30
ORA-00904: 「用戶」, 「CUSTOMER_ID」:無效identifierCompilation失敗,行32
如果你還沒有,我建議你在你的表上定義真正的外鍵。 – 2013-04-29 15:12:04
H,是的那裏已經定義,但感謝提醒 – 2013-04-29 15:36:14