标签: ora-02292

ORA-02292:违反完整性约束 - 在 ORACLE SQL Developer 中创建过程时发现子记录?

我已经编写了一个以 CUSTOMER_ID 作为输入的过程。然后该过程从表 CUSTOMERS 中删除相应的客户。

CREATE OR REPlACE PROCEDURE DELETE_CUSTOMER 
(CUSTOMER_ID NUMBER) AS 
TOT_CUSTOMERS NUMBER;
BEGIN
    DELETE FROM CUSTOMERS
    WHERE CUSTOMERS.CUSTOMER_ID = DELETE_CUSTOMER.CUSTOMER_ID;
    TOT_CUSTOMERS := TOT_CUSTOMERS - 1;
    END;
/
Run Code Online (Sandbox Code Playgroud)

我必须执行删除 ID 为 1 的客户的过程。

EXECUTE DELETE_CUSTOMER(01);
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我收到一个错误

Error starting at line : 120 in command -
BEGIN DELETE_CUSTOMER(01); END;
Error report -
ORA-02292: integrity constraint (TUG81959.ORDERS_FK_CUSTOMERS) violated - child record found
ORA-06512: at "TUG81959.DELETE_CUSTOMER", line 5
ORA-06512: at line 1
02292. 00000 - "integrity constraint (%s.%s) violated - child …
Run Code Online (Sandbox Code Playgroud)

oracle plsql stored-procedures constraints ora-02292

3
推荐指数
1
解决办法
1万
查看次数