【发布时间】:2023-04-11 11:35:01
【问题描述】:
我正在尝试创建一个将结果返回到 php 页面的 sql 过程。
我希望能够从 php 中调用如下程序
call procedure_name($var1)
将运行此脚本:
-- ---------------------------------------------------------------------------------
-- pUIGetCliStmtGenFlag
--
-- This procedure returns the status of the Trading Period:
--
-- ---------------------------------------------------------------------------------
drop procedure if exists pUIGetCliStmtGenFlag;
delimiter //
create procedure pUIGetCliStmtGenFlag(
IN pTradingPeriodMonth DATE
)
MODIFIES SQL DATA
COMMENT 'Checks if the TP has been closed'
begin
SELECT trading_period_month,
dt_end,
amt_traded_system_ccy
FROM ca_trading_period
WHERE trading_period_month=$var1
-- If amt_traded_system_ccy is NULL give the TP an open status otherwise mark as closed
IF amt_traded_system_ccy is NULL
$tpstatus='open'
ELSE
$tpstatus='closed'
end;
//
delimiter ;
然后我希望能够在 php 脚本的其余部分中使用 $tpstatus。
我知道这很简单,但这对我来说是全新的,我找不到正确的方法
【问题讨论】:
标签: php sql variables procedure