Foros del Web » Programando para Internet » PHP »

Store Procedures en SQL Server

Estas en el tema de Store Procedures en SQL Server en el foro de PHP en Foros del Web. Hola a todos, estoy trabajando con un SP llamado SP_REPORTEW_CARTERA_ANALISTA, el cual detallo a continuacion: CREATE PROCEDURE SP_REPORTEW_CARTERA_ANALISTA @COD_AGE varchar (2), @TIPO_PRES varchar (2), @COD_ANA ...
  #1 (permalink)  
Antiguo 27/02/2006, 18:44
Avatar de AmericoOnL  
Fecha de Ingreso: abril-2002
Mensajes: 43
Antigüedad: 22 años
Puntos: 0
Store Procedures en SQL Server

Hola a todos, estoy trabajando con un SP llamado SP_REPORTEW_CARTERA_ANALISTA, el cual detallo a continuacion:

CREATE PROCEDURE SP_REPORTEW_CARTERA_ANALISTA
@COD_AGE varchar (2),
@TIPO_PRES varchar (2),
@COD_ANA varchar (2),
@MONEDA CHAR(1),
@ESTADO CHAR(2),
@OTORGA SMALLDATETIME
AS
SELECT TIPPRES.NOM_PRES AS TipoCredito,
TIPPROD.NOM_PROD AS Producto,
PRESTAMO.CUENTA AS CTA,
PRESTAMO.OTORGA AS OTORGADO,
PRESTAMO.PAGARE AS PAGARE,
PRESTAMO.MONTO_PRESTAMO AS MONTO,
PRESTAMO.SALDO_PRES AS SALDO,
PRESTAMO.FECHA_ULT_PAGO AS ULTPAGO,
PRESTAMO.PLAZO AS PLAZO
FROM CARTERANALISTA INNER JOIN
PRESTAMO ON CARTERANALISTA.PAGARE = PRESTAMO.PAGARE AND CARTERANALISTA.OTORGA = PRESTAMO.OTORGA AND
CARTERANALISTA.CUENTA = PRESTAMO.CUENTA INNER JOIN
TIPPRES ON PRESTAMO.TIPO_PRES = TIPPRES.TIPO_PRES CROSS JOIN TIPPROD
WHERE (CARTERANALISTA.COD_AGE = @COD_AGE) and
(TIPPRES.TIPO_PRES = @TIPO_PRES) and
(CARTERANALISTA.COD_ANA = @COD_ANA) and
(PRESTAMO.MONEDA = @MONEDA) and
(PRESTAMO.ESTADO = @ESTADO) and
(CARTERANALISTA.OTORGA <= @OTORGA)
order by producto asc
------------------------

Bien, hasta ahi todo bonito, el asunto es que no los ejemplos de SP que encontre en la web, aparte de ser escasos, se refieren solo a un SP que devuelve un dato con tipo primitivo (int, char) pero no un set de registros como este, tengo un codigo:

$proc = mssql_init("SP_REPORTEW_CARTERA_ANALISTA", $s);
$cod_age = "01";
$tip_pres = "01";
$cod_ana = "01";
$moneda = "S";
$estado = "01";
$otorga="31/12/2005";

mssql_bind($proc, "@COD_AGE", $cod_age, SQLVARCHAR2);
mssql_bind($proc, "@TIPO_PRES", $tip_pres, SQLVARCHAR2);
mssql_bind($proc, "@COD_ANA", $tip_pres, SQLCHAR1);
mssql_bind($proc, "@MONEDA", $moneda, SQLCHAR1);
mssql_bind($proc, "@ESTADO", $estado, SQLCHAR2);
mssql_bind($proc, "@OTORGA", $otorga, SQLSMALLDATETIME);

mssql_bind($proc, "RETVAL", $salida, SQLVARIANT);
mssql_execute($proc);
mssql_free_statement ($proc);
mssql_close($s);

Por favor agradeceria que alguien me indicara como debo llamar este SP y mostrarlo en la web.
Un abrazo a todos
y que Viva PHP !!!!
Americo Torres
  #2 (permalink)  
Antiguo 27/02/2006, 20:45
Avatar de claudiovega  
Fecha de Ingreso: octubre-2003
Ubicación: Puerto Montt
Mensajes: 3.667
Antigüedad: 20 años, 6 meses
Puntos: 11
Estuve revisando: http://www.php.net/manual/es/function.mssql-execute.php y pude ver que se puede hacer esto:

Código PHP:
$proc mssql_init("SP_REPORTEW_CARTERA_ANALISTA"$s);
$cod_age "01";
$tip_pres "01";
$cod_ana "01";
$moneda "S";
$estado "01";
$otorga="31/12/2005";

mssql_bind($proc"@COD_AGE"$cod_ageSQLVARCHAR2);
mssql_bind($proc"@TIPO_PRES"$tip_presSQLVARCHAR2);
mssql_bind($proc"@COD_ANA"$tip_presSQLCHAR1);
mssql_bind($proc"@MONEDA"$monedaSQLCHAR1);
mssql_bind($proc"@ESTADO"$estadoSQLCHAR2);
mssql_bind($proc"@OTORGA"$otorgaSQLSMALLDATETIME);

mssql_bind($proc"RETVAL"$salidaSQLVARIANT);
$result=mssql_execute($proc);
do {
       while (
$row mssql_fetch_row($rs)) {
            echo 
$row['algun_campo']."<br>";
       }
   } while (
mssql_next_result($rs));
mssql_free_statement ($proc);
mssql_close($s); 
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:30.