{"id":93244,"date":"2024-10-19T12:22:18","date_gmt":"2024-10-19T04:22:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/93244\/"},"modified":"2024-10-19T12:22:18","modified_gmt":"2024-10-19T04:22:18","slug":"ora-53001-%e5%92%8c%e6%a8%99%e7%b1%a4%e5%80%bc%e7%82%ba-null-oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/93244\/","title":{"rendered":"ORA-53001: \u548c\u6a19\u7c64\u503c\u70ba NULL ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406"},"content":{"rendered":"<h1 id=\"ora-53001-%e5%92%8c%e6%a8%99%e7%b1%a4%e5%80%bc%e7%82%ba-null-oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86-aaBHtTebKP\">ORA-53001: \u548c\u6a19\u7c64\u503c\u70ba NULL ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406<\/h1>\n<p>\u5728\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u7684\u904e\u7a0b\u4e2d\uff0c\u958b\u767c\u8005\u548c\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\u4ee3\u78bc\uff0c\u5176\u4e2d\u4e4b\u4e00\u4fbf\u662f <code>ORA-53001<\/code>\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u8207\u6a19\u7c64\u503c\u70ba NULL \u6709\u95dc\uff0c\u4e26\u4e14\u53ef\u80fd\u6703\u5f71\u97ff\u5230\u6578\u64da\u5eab\u7684\u6b63\u5e38\u904b\u884c\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e <code>ORA-53001<\/code> \u932f\u8aa4\u7684\u539f\u56e0\u3001\u5f71\u97ff\u4ee5\u53ca\u4fee\u5fa9\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"ora-53001-%e9%8c%af%e8%aa%a4%e7%9a%84%e5%8e%9f%e5%9b%a0-aaBHtTebKP\">ORA-53001 \u932f\u8aa4\u7684\u539f\u56e0<\/h2>\n<p><code>ORA-53001<\/code> \u932f\u8aa4\u901a\u5e38\u51fa\u73fe\u5728\u4ee5\u4e0b\u60c5\u6cc1\uff1a<\/p>\n<ul>\n<li>\u7576\u57f7\u884c\u67d0\u4e9b SQL \u67e5\u8a62\u6642\uff0c\u7cfb\u7d71\u7121\u6cd5\u627e\u5230\u6240\u9700\u7684\u6a19\u7c64\u503c\u3002<\/li>\n<li>\u5728\u4f7f\u7528 PL\/SQL \u7a0b\u5e8f\u6642\uff0c\u67d0\u4e9b\u8b8a\u91cf\u672a\u6b63\u78ba\u521d\u59cb\u5316\uff0c\u5c0e\u81f4\u5176\u503c\u70ba NULL\u3002<\/li>\n<li>\u5728\u6578\u64da\u5eab\u89f8\u767c\u5668\u6216\u5b58\u5132\u904e\u7a0b\u4e2d\uff0c\u672a\u80fd\u6b63\u78ba\u8655\u7406 NULL \u503c\u3002<\/li>\n<\/ul>\n<p>\u9019\u4e9b\u60c5\u6cc1\u90fd\u53ef\u80fd\u5c0e\u81f4 Oracle \u6578\u64da\u5eab\u7121\u6cd5\u6b63\u78ba\u57f7\u884c\u8acb\u6c42\uff0c\u5f9e\u800c\u5f15\u767c <code>ORA-53001<\/code> \u932f\u8aa4\u3002<\/p>\n<h2 id=\"%e5%bd%b1%e9%9f%bf-aaBHtTebKP\">\u5f71\u97ff<\/h2>\n<p>\u7576\u51fa\u73fe <code>ORA-53001<\/code> \u932f\u8aa4\u6642\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u4ee5\u4e0b\u5f71\u97ff\uff1a<\/p>\n<ul>\n<li>\u6578\u64da\u5eab\u64cd\u4f5c\u4e2d\u65b7\uff0c\u5f71\u97ff\u696d\u52d9\u6d41\u7a0b\u3002<\/li>\n<li>\u7528\u6236\u7121\u6cd5\u8a2a\u554f\u6240\u9700\u7684\u6578\u64da\uff0c\u5f71\u97ff\u7528\u6236\u9ad4\u9a57\u3002<\/li>\n<li>\u53ef\u80fd\u5c0e\u81f4\u6578\u64da\u4e0d\u4e00\u81f4\uff0c\u5f71\u97ff\u6578\u64da\u5b8c\u6574\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9%e6%ad%a5%e9%a9%9f-aaBHtTebKP\">\u6545\u969c\u4fee\u5fa9\u6b65\u9a5f<\/h2>\n<p>\u4fee\u5fa9 <code>ORA-53001<\/code> \u932f\u8aa4\u7684\u904e\u7a0b\u53ef\u4ee5\u5206\u70ba\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5-sql-%e6%9f%a5%e8%a9%a2-aaBHtTebKP\">1. \u6aa2\u67e5 SQL \u67e5\u8a62<\/h3>\n<p>\u9996\u5148\uff0c\u6aa2\u67e5\u5f15\u767c\u932f\u8aa4\u7684 SQL \u67e5\u8a62\u3002\u78ba\u4fdd\u6240\u6709\u7684\u6a19\u7c64\u503c\u90fd\u5df2\u6b63\u78ba\u8a2d\u7f6e\uff0c\u4e26\u4e14\u6c92\u6709 NULL \u503c\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>SELECT * FROM employees WHERE department_id = :dept_id;<\/code><\/pre>\n<p>\u5728\u9019\u500b\u67e5\u8a62\u4e2d\uff0c\u78ba\u4fdd <code>:dept_id<\/code> \u8b8a\u91cf\u5728\u57f7\u884c\u524d\u5df2\u88ab\u6b63\u78ba\u521d\u59cb\u5316\u3002<\/p>\n<h3 id=\"2-%e6%aa%a2%e6%9f%a5-pl-sql-%e7%a8%8b%e5%ba%8f-aaBHtTebKP\">2. \u6aa2\u67e5 PL\/SQL \u7a0b\u5e8f<\/h3>\n<p>\u5982\u679c\u932f\u8aa4\u767c\u751f\u5728 PL\/SQL \u7a0b\u5e8f\u4e2d\uff0c\u6aa2\u67e5\u6240\u6709\u8b8a\u91cf\u7684\u521d\u59cb\u5316\u60c5\u6cc1\u3002\u78ba\u4fdd\u5728\u4f7f\u7528\u8b8a\u91cf\u4e4b\u524d\uff0c\u5df2\u7d93\u70ba\u5176\u8ce6\u4e88\u4e86\u6709\u6548\u7684\u503c\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>DECLARE\n    v_dept_id NUMBER;\nBEGIN\n    v_dept_id := 10; -- \u78ba\u4fdd\u8b8a\u91cf\u5df2\u6b63\u78ba\u521d\u59cb\u5316\n    -- \u5176\u4ed6\u908f\u8f2f\nEND;<\/code><\/pre>\n<h3 id=\"3-%e6%aa%a2%e6%9f%a5%e8%a7%b8%e7%99%bc%e5%99%a8%e5%92%8c%e5%ad%98%e5%84%b2%e9%81%8e%e7%a8%8b-aaBHtTebKP\">3. \u6aa2\u67e5\u89f8\u767c\u5668\u548c\u5b58\u5132\u904e\u7a0b<\/h3>\n<p>\u5982\u679c\u932f\u8aa4\u767c\u751f\u5728\u89f8\u767c\u5668\u6216\u5b58\u5132\u904e\u7a0b\u4e2d\uff0c\u6aa2\u67e5\u6240\u6709\u7684\u908f\u8f2f\uff0c\u78ba\u4fdd\u5728\u8655\u7406\u6578\u64da\u6642\u4e0d\u6703\u51fa\u73fe NULL \u503c\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>CREATE OR REPLACE TRIGGER check_department\nBEFORE INSERT ON employees\nFOR EACH ROW\nBEGIN\n    IF :NEW.department_id IS NULL THEN\n        RAISE_APPLICATION_ERROR(-20001, '\u90e8\u9580 ID \u4e0d\u80fd\u70ba NULL');\n    END IF;\nEND;<\/code><\/pre>\n<h2 id=\"%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86-aaBHtTebKP\">\u9060\u7a0b\u8655\u7406<\/h2>\n<p>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u9032\u884c\u9060\u7a0b\u8655\u7406\u4f86\u89e3\u6c7a <code>ORA-53001<\/code> \u932f\u8aa4\u3002\u9019\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u65b9\u5f0f\u5be6\u73fe\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u9060\u7a0b\u684c\u9762\u5de5\u5177\u9023\u63a5\u5230\u6578\u64da\u5eab\u670d\u52d9\u5668\uff0c\u9032\u884c\u6545\u969c\u6392\u67e5\u3002<\/li>\n<li>\u5229\u7528 Oracle \u7684\u9060\u7a0b\u8a3a\u65b7\u5de5\u5177\uff0c\u6536\u96c6\u932f\u8aa4\u65e5\u8a8c\u548c\u6027\u80fd\u6578\u64da\u3002<\/li>\n<li>\u8207 Oracle \u652f\u6301\u5718\u968a\u806f\u7e6b\uff0c\u7372\u53d6\u5c08\u696d\u7684\u6280\u8853\u652f\u6301\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-aaBHtTebKP\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Oracle \u6578\u64da\u5eab\u4e2d\uff0c<code>ORA-53001<\/code> \u932f\u8aa4\u901a\u5e38\u8207\u6a19\u7c64\u503c\u70ba NULL \u6709\u95dc\uff0c\u53ef\u80fd\u6703\u5c0d\u696d\u52d9\u904b\u884c\u9020\u6210\u5f71\u97ff\u3002\u901a\u904e\u6aa2\u67e5 SQL \u67e5\u8a62\u3001PL\/SQL \u7a0b\u5e8f\u4ee5\u53ca\u89f8\u767c\u5668\u548c\u5b58\u5132\u904e\u7a0b\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u5b9a\u4f4d\u548c\u4fee\u5fa9\u6b64\u932f\u8aa4\u3002\u6b64\u5916\uff0c\u9060\u7a0b\u8655\u7406\u4e5f\u53ef\u4ee5\u4f5c\u70ba\u4e00\u7a2e\u89e3\u6c7a\u65b9\u6848\uff0c\u4ee5\u4fbf\u5feb\u901f\u6062\u5fa9\u7cfb\u7d71\u7684\u6b63\u5e38\u904b\u884c\u3002\u82e5\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u670d\u52d9\u4f86\u652f\u6301\u60a8\u7684\u6578\u64da\u5eab\u904b\u884c\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u6c7a ORA-53001 \u932f\u8aa4\uff0c\u8655\u7406 NULL \u6a19\u7c64\u503c\u554f\u984c\uff0c\u63d0\u4f9b\u6709\u6548\u7684\u6545\u969c\u4fee\u5fa9\u548c\u9060\u7a0b\u652f\u6301\u65b9\u6848\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-93244","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/93244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=93244"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/93244\/revisions"}],"predecessor-version":[{"id":93245,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/93244\/revisions\/93245"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=93244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=93244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=93244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}