
27/09/2011, 09:00
|
| | Fecha de Ingreso: marzo-2010
Mensajes: 22
Antigüedad: 15 años Puntos: 0 | |
Respuesta: Problemas con PHP y Store Procedure SQL Server El Codigo es el siguiente:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Importa Archivo texto Fijo a MSSQL</title>
</head>
<body>
<?php
require("conexion.php") ;
// Connect to the data source and get a handle for that connection.
$connect = odbc_connect($data_source,$user,$password) or die ("No se pudo conectar con BD de Archivo Unico");
if (!$connect)
{
if (phpversion() < '4.0')
{
exit("Conexión a la Base de Datos falla: " . $php_errormsg );
}
if (odbc_error())
{
echo odbc_errormsg("Conexion a la BD falla: " . $connect);
}
}
//En este Store Inicializo las Tablas Intermedias
$sql_1 = "sp_Importa1";
$stmt = odbc_prepare($connect,$sql_1);
odbc_execute($stmt);
odbc_free_result($stmt);
//En este Store inserta en las Tablas Intermedias los datos del Archivo Texto
$sql_2 = "sp_Importa2";
$stmt = odbc_prepare($connect,$sql_2);
odbc_execute($stmt);
odbc_free_result($stmt);
//En este Store inserta en las Tablas definitivas y se TRIPLICAN los datos
$sql_3 = "sp_Importa3";
$stmt = odbc_prepare($connect,$sql_3);
odbc_execute($stmt);
odbc_free_result($stmt);
// Cierra la conexion
odbc_close($connect);
?>
</body>
</html>
Los STORE PROCEDURE funcionan correctamente si son ejecutados desde el Analizador de Consultas de SQL Server. |