{"Entry":{"collection":"sql","key":"execute","name":"EXECUTE","aliases":["execute"],"metadata":{"aliases":["execute"],"changed_in":["8.2"],"changes":[{"from":"7.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"7.3"},{"from":"7.3","purpose_changed":true,"renamed":null,"sections":{"added":["parameters"],"changed":["description","compatibility"],"removed":[]},"status":"changed","synopsis":null,"to":"7.4"},{"from":"7.4","purpose_changed":false,"renamed":null,"sections":{"added":["outputs","examples","see_also"],"changed":[],"removed":[]},"status":"changed","synopsis":null,"to":"8.0"},{"from":"8.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":{"added":["EXECUTE name [ (parameter [, ...] ) ]"],"removed":["EXECUTE plan_name [ (parameter [, ...] ) ]"]},"to":"8.2"},{"from":"12","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["examples"],"removed":[]},"status":"changed","synopsis":null,"to":"13"}],"content_hash":"de2730d2da2f284c70aab606c36893c20d166bb4f57dc02a5d61c47f5de74cbd","derived_content_hash":"bd602454cbca440f93b8a14801f48655a7fea0f4d234d79075faee41d653490f","editorial":{},"first_version":"7.3","group":"cursor","imported_at":"2026-09-30T17:43:39.219401+08:00","last_version":"20","name":"EXECUTE","object":"","position":12003,"present_in":["7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"purpose":"execute a prepared statement","purpose_zh":"","related":["deallocate","prepare"],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:3ec7a162114abd75c65e142ebb20bb59f3cca3362b3e0c67afc42445092ec3a3","receipt_sha256":"ce808083c9c2df6cb303033ed835282aedf6e4e3372ab8eb61581870413b8705","repair":"wiki-repair-20261023"},"slug":"execute","source_rev":"wiki-repair-20261023:ca390920a7790f4a283ce2cf78ac3f33fda5aa6b8678664d7a45e26ddca57fb9","synopsis":"EXECUTE name [ ( parameter [, ...] ) ]","verb":"EXECUTE"}},"Definition":{"Collection":"sql","Key":"execute","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"execute","SourceRevision":"wiki-repair-20261023:ca390920a7790f4a283ce2cf78ac3f33fda5aa6b8678664d7a45e26ddca57fb9","Facts":{"anchor":"SQL-EXECUTE","description_zh":"执行一个预备语句","description_zh_html":"\u003cpre\u003eEXECUTE name [ ( parameter [, ...] ) ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e 用于执行一个先前创建的预备语句。由于预备语句只在一个会话期间内存在，因此该预备语句必须由当前会话中较早执行的 \u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e 语句创建。\n  \u003c/p\u003e\u003cp\u003e\n   如果创建该语句的 \u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e 语句指定了某些参数，那么传递给 \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e 语句的参数集合就必须与之兼容，否则将引发错误。注意，预备语句（不同于函数）不会根据其参数的类型或个数进行重载；预备语句的名称在一个数据库会话内必须唯一。\n  \u003c/p\u003e\u003cp\u003e\n   有关预备语句的创建和用法的更多信息，请参见 \u003ca class=\"xref\" href=\"/zh/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      要执行的预备语句名称。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      预备语句中某个参数的实际值。它必须是一个表达式，并且其求值结果必须与该参数的数据类型兼容，该数据类型在创建预备语句时已确定。\n     \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e输出\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e 返回的命令标签是该预备语句的命令标签，而不是 \u003ccode class=\"literal\"\u003eEXECUTE\u003c/code\u003e。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e\n   示例见 \u003ca class=\"xref\" href=\"/zh/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e 文档中的\u003ca class=\"xref\" href=\"/zh/docs/18/sql-prepare.html#SQL-PREPARE-EXAMPLES\" title=\"示例\"\u003e示例\u003c/a\u003e。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\n   SQL 标准包含 \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e 语句，但它只用于嵌入式 SQL。这里的 \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e 语句还使用了稍有不同的语法。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/zh/docs/18/sql-deallocate.html\" title=\"DEALLOCATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDEALLOCATE\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","file":"sql-execute.html","lang":"en","name":"EXECUTE","purpose":"execute a prepared statement","purpose_zh":"执行一个预备语句","related":["deallocate","prepare"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e is used to execute a previously prepared statement. Since prepared statements only exist for the duration of a session, the prepared statement must have been created by a \u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e statement executed earlier in the current session.\u003c/p\u003e\u003cp\u003eIf the \u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e statement that created the statement specified some parameters, a compatible set of parameters must be passed to the \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement, or else an error is raised. Note that (unlike functions) prepared statements are not overloaded based on the type or number of their parameters; the name of a prepared statement must be unique within a database session.\u003c/p\u003e\u003cp\u003eFor more information on the creation and usage of prepared statements, see \u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the prepared statement to execute.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe actual value of a parameter to the prepared statement. This must be an expression yielding a value that is compatible with the data type of this parameter, as was determined when the prepared statement was created.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eThe command tag returned by \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e is that of the prepared statement, and not \u003ccode class=\"literal\"\u003eEXECUTE\u003c/code\u003e.\u003c/p\u003e","key":"outputs","title":"Outputs"},{"html":"\u003cp\u003eExamples are given in \u003ca href=\"/docs/18/sql-prepare.html#SQL-PREPARE-EXAMPLES\" title=\"Examples\"\u003eExamples\u003c/a\u003e in the \u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e documentation.\u003c/p\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThe SQL standard includes an \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement, but it is only for use in embedded SQL. This version of the \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement also uses a somewhat different syntax.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/deallocate/?v=18\" title=\"DEALLOCATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDEALLOCATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/prepare/?v=18\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"EXECUTE \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e [, ...] ) ]","synopsis_text":"EXECUTE name [ ( parameter [, ...] ) ]","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/sql-execute.html","sha256":"bc5301ea77f13a16fee62a9ab889ef5734f56c09efbc87825ee5ab4161e4131f"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-pgdoc"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"execute","SourceDatabase":"center","Version":"18","Locale":"en","Title":"EXECUTE","Summary":"execute a prepared statement","BodyHTML":"\u003cpre\u003eEXECUTE name [ ( parameter [, ...] ) ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eEXECUTE\u003c/code\u003e is used to execute a previously prepared statement. Since prepared statements only exist for the duration of a session, the prepared statement must have been created by a \u003ccode\u003ePREPARE\u003c/code\u003e statement executed earlier in the current session.\u003c/p\u003e\u003cp\u003eIf the \u003ccode\u003ePREPARE\u003c/code\u003e statement that created the statement specified some parameters, a compatible set of parameters must be passed to the \u003ccode\u003eEXECUTE\u003c/code\u003e statement, or else an error is raised. Note that (unlike functions) prepared statements are not overloaded based on the type or number of their parameters; the name of a prepared statement must be unique within a database session.\u003c/p\u003e\u003cp\u003eFor more information on the creation and usage of prepared statements, see \u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\" rel=\"nofollow\"\u003e\u003cspan\u003ePREPARE\u003c/span\u003e\u003c/a\u003e.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eParameters\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the prepared statement to execute.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe actual value of a parameter to the prepared statement. This must be an expression yielding a value that is compatible with the data type of this parameter, as was determined when the prepared statement was created.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eOutputs\u003c/h2\u003e\u003cp\u003eThe command tag returned by \u003ccode\u003eEXECUTE\u003c/code\u003e is that of the prepared statement, and not \u003ccode\u003eEXECUTE\u003c/code\u003e.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003eExamples are given in \u003ca href=\"/docs/18/sql-prepare.html#SQL-PREPARE-EXAMPLES\" title=\"Examples\" rel=\"nofollow\"\u003eExamples\u003c/a\u003e in the \u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\" rel=\"nofollow\"\u003e\u003cspan\u003ePREPARE\u003c/span\u003e\u003c/a\u003e documentation.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eCompatibility\u003c/h2\u003e\u003cp\u003eThe SQL standard includes an \u003ccode\u003eEXECUTE\u003c/code\u003e statement, but it is only for use in embedded SQL. This version of the \u003ccode\u003eEXECUTE\u003c/code\u003e statement also uses a somewhat different syntax.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/deallocate/?v=18\" title=\"DEALLOCATE\" rel=\"nofollow\"\u003e\u003cspan\u003eDEALLOCATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/prepare/?v=18\" title=\"PREPARE\" rel=\"nofollow\"\u003e\u003cspan\u003ePREPARE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"wiki-repair-20261023:ca390920a7790f4a283ce2cf78ac3f33fda5aa6b8678664d7a45e26ddca57fb9","ContentHash":"c723dde4c101eeeee4dd331f7b284a1cdf1413574dcb022604c262ac720fc5c4","Payload":{"related":["deallocate","prepare"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e is used to execute a previously prepared statement. Since prepared statements only exist for the duration of a session, the prepared statement must have been created by a \u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e statement executed earlier in the current session.\u003c/p\u003e\u003cp\u003eIf the \u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e statement that created the statement specified some parameters, a compatible set of parameters must be passed to the \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement, or else an error is raised. Note that (unlike functions) prepared statements are not overloaded based on the type or number of their parameters; the name of a prepared statement must be unique within a database session.\u003c/p\u003e\u003cp\u003eFor more information on the creation and usage of prepared statements, see \u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the prepared statement to execute.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe actual value of a parameter to the prepared statement. This must be an expression yielding a value that is compatible with the data type of this parameter, as was determined when the prepared statement was created.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eThe command tag returned by \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e is that of the prepared statement, and not \u003ccode class=\"literal\"\u003eEXECUTE\u003c/code\u003e.\u003c/p\u003e","key":"outputs","title":"Outputs"},{"html":"\u003cp\u003eExamples are given in \u003ca href=\"/docs/18/sql-prepare.html#SQL-PREPARE-EXAMPLES\" title=\"Examples\"\u003eExamples\u003c/a\u003e in the \u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e documentation.\u003c/p\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThe SQL standard includes an \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement, but it is only for use in embedded SQL. This version of the \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement also uses a somewhat different syntax.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/deallocate/?v=18\" title=\"DEALLOCATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDEALLOCATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/prepare/?v=18\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","synopsis_html":"EXECUTE \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e [, ...] ) ]","synopsis_text":"EXECUTE name [ ( parameter [, ...] ) ]"}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
