Prepared Statements

SET variables 指定變數

@ 標示變數名稱
SET @p=100, @q=5;
SELECT @p AS Price, @q AS Qty, @p*@q AS Amount;
SELECT @p:=200 AS Price, @q:=6 AS Qty, @p*@q AS Amount;

備好 SQL statement

PREPARE 定義 statement
PREPARE stmt1 FROM 'SELECT ?*10';

自定名稱 stmt1prepared statement

SET (指定值)
SET @x=3;
EXECUTE 執行 prepared statement
EXECUTE stmt1 USING @x;
綜合
PREPARE stmt2 FROM 'SELECT ? AS Price, ? AS Discount, ?*? AS Selling';
SET @p=100,@d=0.8;
EXECUTE stmt2 USING @p,@d,@p,@d;
SET @p=200;
EXECUTE stmt2 USING @p,@d,@p,@d;
SET @d=0.69;
EXECUTE stmt2 USING @p,@d,@p,@d;
參考資源

更新日期:

google 論壇

App javascript (groups.google.com/group/app-javascript/)