解析:php调用MsSQL存储过程使用内置RETVAL获取过程中的return值
【PHP代码】
$stmt = mssql_init('P__Global_Test', $conn) or die("initialize stored procedure failure");
mssql_bind($stmt, "RETVAL", $returnValue, SQLINT4, true);
mssql_execute($stmt, false);
if( $returnValue == 0 ){
echo 'ABCD';
}
else{ <PRE class=php name="code"> echo 'EFGH';</PRE> }
【存储过程】
CREATE PROCEDURE dbo.P__User_JudgeResume(
)
set nocount on
set @Message = ''
if not exists( select * from _Test )
begin
return 0
end
else
begin
return 1
end
set nocount off
GO
复制代码 代码如下:
$stmt = mssql_init('P__Global_Test', $conn) or die("initialize stored procedure failure");
mssql_bind($stmt, "RETVAL", $returnValue, SQLINT4, true);
mssql_execute($stmt, false);
if( $returnValue == 0 ){
echo 'ABCD';
}
else{ <PRE class=php name="code"> echo 'EFGH';</PRE> }
【存储过程】
复制代码 代码如下:
CREATE PROCEDURE dbo.P__User_JudgeResume(
)
set nocount on
set @Message = ''
if not exists( select * from _Test )
begin
return 0
end
else
begin
return 1
end
set nocount off
GO