{"id":21337,"date":"2024-01-02T07:42:26","date_gmt":"2024-01-02T07:42:26","guid":{"rendered":"https:\/\/server.hk\/blog\/21337\/"},"modified":"2024-11-14T10:36:29","modified_gmt":"2024-11-14T02:36:29","slug":"how-to-fix-postgresql-error-code-2203c-sql_json_object_not_found","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21337\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a2203C &#8211; sql_json_object_not_found"},"content":{"rendered":"<h1 id=\"how-to-fix-postgresql-error-code-2203c-sql_json_object_not_found-VDzPABSUFW\">\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a2203C &#8211; sql_json_object_not_found<\/h1>\n<p>PostgreSQL \u662f\u4e00\u6b3e\u529f\u80fd\u5f37\u5927\u7684\u958b\u6e90\u95dc\u806f\u5f0f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5f0f\u3002\u7136\u800c\uff0c\u50cf\u4efb\u4f55\u8edf\u9ad4\u4e00\u6a23\uff0c\u5b83\u4e5f\u53ef\u80fd\u6703\u9047\u5230\u932f\u8aa4\uff0c\u5e72\u64fe\u5176\u6b63\u5e38\u904b\u4f5c\u3002\u5176\u4e2d\u4e00\u500b\u932f\u8aa4\u662f PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a2203C &#8211; sql_json_object_not_found\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u6b64\u932f\u8aa4\u7684\u6210\u56e0\u4e26\u63d0\u4f9b\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n<h2 id=\"understanding-the-error-VDzPABSUFW\">\u7406\u89e3\u932f\u8aa4<\/h2>\n<p>PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a2203C &#8211; sql_json_object_not_found \u767c\u751f\u65bc\u8cc7\u6599\u5eab\u4e2d\u627e\u4e0d\u5230 JSON \u7269\u4ef6\u6642\u3002\u7576\u8a66\u5716\u4f7f\u7528 PostgreSQL \u7684 JSON \u51fd\u6578\u6216\u904b\u7b97\u7b26\u4f86\u8a2a\u554f\u6216\u64cd\u4f5c JSON \u6578\u64da\u6642\uff0c\u901a\u5e38\u6703\u51fa\u73fe\u6b64\u932f\u8aa4\u3002<\/p>\n<p>\u7576\u60a8\u9047\u5230\u6b64\u932f\u8aa4\u6642\uff0c\u53ef\u80fd\u6703\u770b\u5230\u985e\u4f3c\u4ee5\u4e0b\u7684\u932f\u8aa4\u8a0a\u606f\uff1a<\/p>\n<p><code>ERROR:  sql_json_object_not_found<\/code><\/p>\n<p>\u9019\u689d\u932f\u8aa4\u8a0a\u606f\u8868\u660e\u60a8\u8a66\u5716\u8a2a\u554f\u6216\u64cd\u4f5c\u7684 JSON \u7269\u4ef6\u5728\u8cc7\u6599\u5eab\u4e2d\u4e26\u4e0d\u5b58\u5728\u3002<\/p>\n<h2 id=\"possible-causes-VDzPABSUFW\">\u53ef\u80fd\u7684\u6210\u56e0<\/h2>\n<p>PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a2203C &#8211; sql_json_object_not_found \u53ef\u80fd\u7684\u6f5b\u5728\u539f\u56e0\u6709\uff1a<\/p>\n<ul>\n<li><strong>\u7f3a\u5931\u7684 JSON \u7269\u4ef6\uff1a<\/strong> \u60a8\u8a66\u5716\u8a2a\u554f\u6216\u64cd\u4f5c\u7684 JSON \u7269\u4ef6\u5728\u8cc7\u6599\u5eab\u4e2d\u4e26\u4e0d\u5b58\u5728\u3002<\/li>\n<li><strong>\u4e0d\u6b63\u78ba\u7684 JSON \u8def\u5f91\uff1a<\/strong> \u7528\u4f86\u8a2a\u554f\u6216\u64cd\u4f5c JSON \u7269\u4ef6\u7684 JSON \u8def\u5f91\u4e0d\u6b63\u78ba\u3002<\/li>\n<li><strong>\u7121\u6548\u7684 JSON \u6578\u64da\uff1a<\/strong> \u5b58\u5132\u65bc\u8cc7\u6599\u5eab\u4e2d\u7684 JSON \u6578\u64da\u7121\u6548\u6216\u5df2\u640d\u58de\u3002<\/li>\n<\/ul>\n<h2 id=\"fixing-the-error-VDzPABSUFW\">\u4fee\u5fa9\u932f\u8aa4<\/h2>\n<p>\u8981\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a2203C &#8211; sql_json_object_not_found\uff0c\u60a8\u53ef\u4ee5\u9075\u5faa\u4ee5\u4e0b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-verify-json-object-existence-VDzPABSUFW\">1. \u9a57\u8b49 JSON \u7269\u4ef6\u7684\u5b58\u5728<\/h3>\n<p>\u9996\u5148\uff0c\u78ba\u4fdd\u60a8\u8a66\u5716\u8a2a\u554f\u6216\u64cd\u4f5c\u7684 JSON \u7269\u4ef6\u78ba\u5be6\u5b58\u5728\u65bc\u8cc7\u6599\u5eab\u4e2d\u3002\u4ed4\u7d30\u6aa2\u67e5\u8868\u53ca\u6b04\u4f4d\u540d\u7a31\u4ee5\u78ba\u4fdd\u5176\u6b63\u78ba\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 SELECT \u8a9e\u53e5\u4f86\u78ba\u8a8d JSON \u7269\u4ef6\u7684\u5b58\u5728\uff1a<\/p>\n<pre><code>SELECT * FROM your_table WHERE your_column_name ? 'your_json_object_key';\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8a72\u67e5\u8a62\u4e0d\u8fd4\u56de\u4efb\u4f55\u7d50\u679c\uff0c\u5247\u610f\u5473\u8457\u8a72 JSON \u7269\u4ef6\u5728\u6307\u5b9a\u7684\u6b04\u4f4d\u4e2d\u4e0d\u5b58\u5728\u3002<\/p>\n<h3 id=\"2-check-json-path-VDzPABSUFW\">2. \u6aa2\u67e5 JSON \u8def\u5f91<\/h3>\n<p>\u6aa2\u67e5\u60a8\u7528\u4f86\u8a2a\u554f\u6216\u64cd\u4f5c JSON \u7269\u4ef6\u7684 JSON \u8def\u5f91\u3002\u78ba\u4fdd\u8a72\u8def\u5f91\u6b63\u78ba\u4e14\u7b26\u5408\u8cc7\u6599\u5eab\u4e2d\u5b58\u5132\u7684 JSON \u6578\u64da\u7d50\u69cb\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 PostgreSQL \u63d0\u4f9b\u7684 JSON \u8def\u5f91\u51fd\u6578\u4f86\u9a57\u8b49\u4e26\u63d0\u53d6 JSON \u7269\u4ef6\u4e2d\u7684\u6578\u64da\u3002<\/p>\n<h3 id=\"3-validate-json-data-VDzPABSUFW\">3. \u9a57\u8b49 JSON \u6578\u64da<\/h3>\n<p>\u5982\u679c\u5b58\u5132\u5728\u8cc7\u6599\u5eab\u4e2d\u7684 JSON \u6578\u64da\u7121\u6548\u6216\u5df2\u640d\u58de\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230 sql_json_object_not_found \u932f\u8aa4\u3002\u8acb\u4f7f\u7528 PostgreSQL \u4e2d\u53ef\u7528\u7684 JSON \u9a57\u8b49\u5de5\u5177\u6216\u51fd\u6578\uff0c\u9a57\u8b49 JSON \u6578\u64da\u4e26\u4fee\u5fa9\u4efb\u4f55\u554f\u984c\u3002<\/p>\n<h3 id=\"4-update-or-insert-json-object-VDzPABSUFW\">4. \u66f4\u65b0\u6216\u63d2\u5165 JSON \u7269\u4ef6<\/h3>\n<p>\u5982\u679c JSON \u7269\u4ef6\u7f3a\u5931\u6216\u672a\u627e\u5230\uff0c\u60a8\u53ef\u4ee5\u5728\u8cc7\u6599\u5eab\u4e2d\u66f4\u65b0\u6216\u63d2\u5165\u8a72 JSON \u7269\u4ef6\u3002\u4f7f\u7528 UPDATE \u6216 INSERT \u8a9e\u53e5\u4f86\u4fee\u6539\u6216\u65b0\u589e JSON \u7269\u4ef6\u81f3\u9069\u7576\u7684\u8868\u53ca\u6b04\u4f4d\u3002<\/p>\n<h2 id=\"summary-VDzPABSUFW\">\u7e3d\u7d50<\/h2>\n<p>\u7e3d\u4e4b\uff0cPostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a2203C &#8211; sql_json_object_not_found \u662f\u6307\u5728\u8cc7\u6599\u5eab\u4e2d\u627e\u4e0d\u5230 JSON \u7269\u4ef6\u3002\u8981\u4fee\u5fa9\u6b64\u932f\u8aa4\uff0c\u8acb\u9a57\u8b49 JSON \u7269\u4ef6\u7684\u5b58\u5728\u3001\u6aa2\u67e5 JSON \u8def\u5f91\u3001\u9a57\u8b49 JSON \u6578\u64da\uff0c\u4ee5\u53ca\u5728\u5fc5\u8981\u6642\u66f4\u65b0\u6216\u63d2\u5165 JSON \u7269\u4ef6\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u9047\u5230 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a2203C &#8211; sql_json_object_not_found \u6216\u5176\u4ed6\u4efb\u4f55 PostgreSQL \u76f8\u95dc\u554f\u984c\uff0c\u8003\u616e\u5229\u7528\u53ef\u9760\u7684 VPS \u8a17\u7ba1\u670d\u52d9\u63d0\u4f9b\u5546\uff0c\u5982 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002\u901a\u904e\u4ed6\u5011\u7684\u4e00\u6d41 VPS \u89e3\u6c7a\u65b9\u6848\uff0c\u60a8\u53ef\u4ee5\u78ba\u4fdd\u60a8\u7684 PostgreSQL \u6578\u64da\u5eab\u7372\u5f97\u6700\u4f73\u6027\u80fd\u548c\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4fee\u5fa9 PostgreSQL &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-21337","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21337","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=21337"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21337\/revisions"}],"predecessor-version":[{"id":24168,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21337\/revisions\/24168"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}