概要

EXECUTE statement_name [ USING parameter1 [ , parameter2, ... ] ]

描述

执行预编译查询, 使用USING子句按位置传参。

示例

  • 示例 1:
    PREPARE my_select1 FROM
    SELECT name FROM nation;
    --- 执行预编译查询
    EXECUTE my_select1;
    示例2
  • 示例 2:
    PREPARE my_select2 FROM
    SELECT name FROM nation WHERE regionkey = ? and nationkey < ?;
    --- 执行预编译查询
    EXECUTE my_select2 USING 1, 3; 
    --- 上述语句等价与执行如下查询:
    SELECT name FROM nation WHERE regionkey = 1 AND nationkey < 3;