Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/09/2007, 07:58
Avatar de Scour
Scour
 
Fecha de Ingreso: octubre-2003
Ubicación: Murcia (España)
Mensajes: 94
Antigüedad: 20 años, 6 meses
Puntos: 0
Error al ejecutar Store Procedure SQL Server 2000 desde PHP

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:

Código PHP:
Warningmssql_execute() [function.mssql-execute]: stored procedure execution failed in /var/www/web/intranet/recogida.php on line 239 
El código de PHP es:

Código PHP:
$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:

Cita:
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.