msphpsql/test/functional/sqlsrv/sqlsrv_stored_proc_varchar....

69 строки
1.8 KiB
Plaintext
Исходник Обычный вид История

2017-02-24 08:40:51 +03:00
--TEST--
Test stored procedure that returns a varchar
2017-11-30 01:40:47 +03:00
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
2017-02-24 08:40:51 +03:00
--FILE--
<?php
require_once('MsCommon.inc');
2017-02-24 08:40:51 +03:00
2017-11-30 01:40:47 +03:00
function storedProcVarchar()
2017-02-24 08:40:51 +03:00
{
set_time_limit(0);
sqlsrv_configure('WarningsReturnAsErrors', 1);
// connect
2017-11-30 01:40:47 +03:00
$conn = AE\connect();
2017-02-24 08:40:51 +03:00
2017-11-30 01:40:47 +03:00
$procName = 'sp_varchar';
dropProc($conn, $procName);
2017-02-24 08:40:51 +03:00
$tsql = "CREATE PROC $procName (@p1 VARCHAR(37) OUTPUT, @p2 VARCHAR(21), @p3 VARCHAR(14))
AS
BEGIN
SET @p1 = CONVERT(VARCHAR(37), @p2 + @p3)
2017-02-24 08:40:51 +03:00
END";
$stmt = sqlsrv_query($conn, $tsql);
sqlsrv_free_stmt($stmt);
$retValue = '';
$stmt = sqlsrv_prepare($conn, "{CALL $procName (?, ?, ?)}", array(array(&$retValue, SQLSRV_PARAM_OUT, null, SQLSRV_SQLTYPE_NVARCHAR(38)), array('Microsoft SQL Server ', SQLSRV_PARAM_IN), array('Driver for PHP', SQLSRV_PARAM_IN)));
$retValue = '';
sqlsrv_execute($stmt);
2017-02-24 08:40:51 +03:00
echo("$retValue\n");
$retValue = 'Microsoft SQL Server Driver for PH';
sqlsrv_execute($stmt);
2017-02-24 08:40:51 +03:00
echo("$retValue\n");
$retValue = 'ABCDEFGHIJKLMNOPQRSTUWXYZMicrosoft ';
sqlsrv_execute($stmt);
2017-02-24 08:40:51 +03:00
echo("$retValue\n");
$retValue = 'ABCDEFGHIJKLMNOPQRSTUWXYZ_Microsoft SQL Server Driver for PHP';
sqlsrv_execute($stmt);
2017-02-24 08:40:51 +03:00
echo("$retValue\n");
$retValue = 'Microsoft SQL Server Driver for';
sqlsrv_execute($stmt);
2017-02-24 08:40:51 +03:00
echo("$retValue\n");
sqlsrv_free_stmt($stmt);
2017-11-30 01:40:47 +03:00
dropProc($conn, $procName);
sqlsrv_close($conn);
2017-02-24 08:40:51 +03:00
}
2017-11-30 01:40:47 +03:00
echo "\nTest begins...\n";
try {
storedProcVarchar();
} catch (Exception $e) {
echo $e->getMessage();
2017-02-24 08:40:51 +03:00
}
2017-11-30 01:40:47 +03:00
echo "\nDone\n";
2017-02-24 08:40:51 +03:00
?>
--EXPECT--

Test begins...
2017-02-24 08:40:51 +03:00
Microsoft SQL Server Driver for PHP
Microsoft SQL Server Driver for PHP
Microsoft SQL Server Driver for PHP
Microsoft SQL Server Driver for PHP
Microsoft SQL Server Driver for PHP
Done