{"id":665,"date":"2019-08-19T14:16:21","date_gmt":"2019-08-19T06:16:21","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=665"},"modified":"2019-11-19T15:13:29","modified_gmt":"2019-11-19T07:13:29","slug":"inceptor-pl-sql-%e4%b8%ad-11073-%e9%94%99%e8%af%af%e7%9a%84%e5%87%a0%e7%a7%8d%e5%b8%b8%e8%a7%81%e5%9c%ba%e6%99%af%e5%92%8c%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=665","title":{"rendered":"Inceptor PL SQL \u4e2d 11073 \u9519\u8bef\u7684\u51e0\u79cd\u5e38\u89c1\u573a\u666f\u548c\u89e3\u51b3\u529e\u6cd5"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>&emsp;\u672c\u6587\u6863\u57fa\u4e8e <a href=\"https:\/\/www.warpcloud.cn\/#\/documents-support\/docs-detail\/document\/TDH-OPS\/6.2\/050ErrorManual?docType=products%3Fcategory%3DTDH&docName=Inceptor%E9%94%99%E8%AF%AF%E4%BB%A3%E7%A0%81%E4%B8%8E%E4%BF%A1%E6%81%AF%E6%9F%A5%E8%AF%A2%E6%89%8B%E5%86%8C\">Inceptor\u9519\u8bef\u4ee3\u7801\u4e0e\u4fe1\u606f\u67e5\u8be2\u624b\u518c<\/a> 10.23 \u5c0f\u8282\u7684 ERROR_11073 \u201cNumber of placeholders {0} doesn\u2019t match number of arguments {1} for dynamic sql: {2}\u201d \u9519\u8bef\uff0c\u5217\u51fa\u4e86\u51e0\u79cd\u5e38\u89c1\u573a\u666f\u548c\u89e3\u51b3\u65b9\u6cd5\uff0c\u6b22\u8fce\u8865\u5145\u5173\u4e8e\u8be5\u95ee\u9898\u7684\u66f4\u591a\u573a\u666f\u3002<br \/>\n<\/br><\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<ul>\n<li><strong>Case 1: EXECUTE IMMEDIATE \u5411\u5176\u540e\u6267\u884c\u7684SQL\u8bed\u53e5\u4f20\u9012\u7684\u53c2\u6570\u6570\u91cf\uff0c\u548c\u539f\u8bed\u53e5\u5b9a\u4e49\u7684\u5339\u914d\u53c2\u6570\u6570\u91cf\u4e0d\u4e00\u81f4<\/strong><br \/>\n&emsp;\u5982\u4e0b\u8fc7\u7a0b\uff1a<\/li>\n<\/ul>\n<pre><code class=\"language-sql\">CREATE OR REPLACE PROCEDURE test_11073()\nIS \nDECLARE \n    v_sql STRING;\n\nBEGIN \n    EXECUTE IMMEDIATE \"DROP TABLE IF EXISTS tab_11073\"; \n    EXECUTE IMMEDIATE \"CREATE TABLE tab_11073(c1 INT, c2 STRING, c3 STRING) \n                        CLUSTERED BY(c1) INTO 1 BUCKETS STORED AS ORC_TRANSACTION\";\n    v_sql := \"INSERT INTO tab_11073 VALUES (:v_c1, :v_c2, :v_c3)\";\n    EXECUTE IMMEDIATE v_sql USING 1,'A','B','C';\nEND; \n\/\nCALL test_11073();<\/code><\/pre>\n<p>&emsp;<strong>\u5206\u6790<\/strong>\uff1a\u8be5 case \u662f\u5f88\u660e\u663e\u7684\u624b\u518c\u91cc\u63cf\u8ff0\u7684\u573a\u666f\uff0c\u5728 EXECUTE IMMEDIATE \u540e USING \u7684\u53c2\u6570\u6570\u91cf\u4e3a 4 \u4e2a\uff0c\u800c v_sql \u8bed\u53e5\u91cc\u7ed1\u5b9a\u53d8\u91cf\u53c2\u6570\u53ea\u6709 3 \u4e2a\uff0c\u6545\u800c\u62a5\u53c2\u6570\u6570\u91cf\u4e0d\u4e00\u81f4\u3002<\/p>\n<p>&emsp;<strong>\u89e3\u51b3\u529e\u6cd5<\/strong>\uff1aUSING \u540e\u9762\u7684\u53c2\u6570\u6570\u91cf\u548c\u539f SQL \u91cc\u7ed1\u5b9a\u7684\u53c2\u6570\u6570\u91cf\u4fdd\u6301\u4e00\u81f4\uff0c\u5199\u5b58\u8fc7\u65f6\u7ec6\u5fc3\u5373\u53ef\u3002<br \/>\n<\/br><\/p>\n<ul>\n<li><strong>Case 2: EXECUTE IMMEDIATE \u540e\u6267\u884c\u7684 SQL\u8bed\u53e5\u542b\u6709\u5e26 &quot;:&quot; \u5e38\u91cf<\/strong><br \/>\n&emsp;\u5982\u4e0b\u8fc7\u7a0b\uff1a<\/li>\n<\/ul>\n<pre><code class=\"language-sql\">CREATE OR REPLACE PROCEDURE test_11073()\nIS \nDECLARE \n    v_sql STRING;\n\nBEGIN \n    EXECUTE IMMEDIATE \"SELECT '2019-08-19 13:00:00 a:b:c' FROM system.dual\" INTO v_sql; \n    DBMS_OUTPUT.PUT_LINE(v_sql);\nEND; \n\/\nCALL test_11073();<\/code><\/pre>\n<p>&emsp;<strong>\u5206\u6790<\/strong>\uff1a\u8be5 case \u4e2d\uff0cEXECUTE IMMEDIATE \u540e\u7684 SQL \u8bed\u53e5\u91cc\u542b\u6709\u5e26 &quot;:&quot; \u7684\u5e38\u91cf\uff0c\u6545\u800c\u5728\u6267\u884c\u8be5\u52a8\u6001 SQL \u65f6\u4f1a\u628a &quot;:&quot; \u540e\u7684\u503c\u5f53\u4f5c\u53c2\u6570\uff0c\u51e0\u4e2a &quot;:&quot; \u5c31\u8ba4\u4e3a\u6709\u51e0\u4e2a\u53c2\u6570 \uff0c\u6240\u4ee5\u4f1a\u62a5 Number of placeholders 4 doesn\u2019t match number of arguments 0.<\/p>\n<p>&emsp;<strong>\u89e3\u51b3\u529e\u6cd5<\/strong>\uff1a\u5c06 &#8216;2019-08-19 13:00:00 a:b:c&#8217; \u91cc\u7684 &quot;:&quot; \u7528 &quot;&#092;:&quot; \u8f6c\u4e49<br \/>\n<\/br><\/p>\n<ul>\n<li><strong>Case 3: EXECUTE IMMEDIATE \u540e\u6267\u884c\u7684 SQL\u8bed\u53e5\u542b\u6709\u5e26 &quot;:&quot; \u53d8\u91cf<\/strong><br \/>\n&emsp;\u5982\u4e0b\u8fc7\u7a0b\uff1a<\/li>\n<\/ul>\n<pre><code class=\"language-sql\">CREATE OR REPLACE PROCEDURE test_11073()\nIS \nDECLARE \n    v_sql STRING;\n    v_ARG TIMESTAMP := SYSDATE; \n    v_ARG_CHG STRING := REPLACE(v_ARG,':','\\:');\n\nBEGIN \n    v_sql := \"SELECT '\" || v_ARG ||  \"' FROM system.dual\";\n    EXECUTE IMMEDIATE v_sql; \n    DBMS_OUTPUT.PUT_LINE(v_sql);\nEND; \n\/\nCALL test_11073();<\/code><\/pre>\n<p>&emsp;<strong>\u5206\u6790<\/strong>\uff1a\u8be5 case \u4e2d\uff0cEXECUTE IMMEDIATE \u540e\u6267\u884c\u7684 v_sql \u7684 SQL \u8bed\u53e5\u91cc\u5e26\u6709\u53d8\u91cf v_ARG\uff0c\u8be5\u53d8\u91cf\u6570\u636e\u7c7b\u578b\u4e3a TIMESTAMP\uff0c\u5176\u503c\u91cc\u5e26\u6709 &quot;:&quot; \u6240\u4ee5\u4f1a\u62a5 Number of placeholders 2 doesn\u2019t match number of arguments 0.<\/p>\n<p>&emsp;<strong>\u89e3\u51b3\u529e\u6cd5<\/strong>\uff1a\u5c06 v_ARG \u53d8\u91cf\u91cc\u7684 &quot;:&quot; \u7528 &quot;&#092;:&quot; \u66ff\u6362\uff0c\u5982\u4e0a\u9762 Case3 \u4e2d\u5b9a\u4e49\u7684 <code> v_ARG_CHG STRING := REPLACE(v_ARG,&#039;:&#039;,&#039;\\:&#039;) <\/code> , \u7136\u540e\u5c06 v_sql \u91cc\u7684 v_ARG \u66ff\u6362\u4e3a v_ARG_CHG.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 &emsp;\u672c\u6587\u6863\u57fa\u4e8e Inceptor\u9519\u8bef\u4ee3\u7801\u4e0e\u4fe1\u606f\u67e5\u8be2\u624b\u518c 10.23 \u5c0f\u8282\u7684 ERROR_11 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=665\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40,1],"tags":[71,72],"class_list":["post-665","post","type-post","status-publish","format-standard","hentry","category-sql_issue","category-uncategorized","tag-71","tag-sqlexecute-immediate"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=665"}],"version-history":[{"count":3,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/665\/revisions"}],"predecessor-version":[{"id":10585,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/665\/revisions\/10585"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}