PHP - Error al ejecutar Store Procedure SQL Server - PHP

 
Vista:

Error al ejecutar Store Procedure SQL Server - PHP

Publicado por Scour (1 intervención) el 10/09/2007 16:54:34
Muy buenas,

Estoy intentando ejecutar un procedimiento almacenado en SQL Server 2000 desde php 5 instalado en un Linux (Debian).

El mensaje de error es el siguiente:

Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in /var/www/web/intranet/recogida.php on line 239

El código de PHP es:

$conSQL = mssql_connect('IP-Servidor','usuario','password') or die ("No se puede conectar a SQL Server.");
mssql_select_db("DBName",$conSQL);
$stmt = mssql_init("expediente",$conSQL);
mssql_bind($stmt,"RETVAL",&$exp_num,SQLINT2);
mssql_execute($stmt);
unset($stmt);

y por último, por si fuese también necesario, el procedimiento almacenado es:

CREATE procedure expediente as

declare @num int
declare @Error int

begin tran
select @num = num_expe from tabla
update tabla set num_expe = num_expe + 1
SET @Error=@@ERROR
if (@Error<>0) goto TratarError
commit tran

TratarError:

if @@Error<>0
begin
rollback tran
select @num = -1
end

return(select @num)
GO

El procedimiento almacenado funciona perfectamente ejecutándolo desde SQL Server...

Muchas gracias por su respuesta.

Un saludo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder