Passing variables from SQL proceedure to PHP
Posted
by
Sam Corbet
on Stack Overflow
See other posts from Stack Overflow
or by Sam Corbet
Published on 2012-06-03T13:57:01Z
Indexed on
2012/06/03
16:40 UTC
Read the original article
Hit count: 225
I am trying to create an sql proceedure that will return the results back to the php page.
I want to be able to call the procedure as follows from the php
call procedure_name($var1)
which will run this script:
-- ---------------------------------------------------------------------------------
-- 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 ;
I then want to be able to use $tpstatus
in the rest of the php script.
I know this is simple but this is completely new to me and I cant find the correct method
© Stack Overflow or respective owner