Problemas con fecha

From: Eduardo Bieñkowski <ebienkowski(at)msp(dot)gub(dot)uy>
To: <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Problemas con fecha
Date: 2006-08-15 17:33:45
Message-ID: 000601c6c090$f58e5fd0$2004010a@hprat
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

pg_query() [function.pg-query]: Query failed: ERROR: Bad date external representation
Este error me lo envia cuando leo de un tabla y quiero grabar en otra.

Mi codigo es:
$archivo = file("dbsinval.dat");
$lineas = count($archivo);
$i=0;
$server = $archivo[$i];
$port=$archivo[$i+1];
$database=$archivo[$i+2];
$dbpass=$archivo[$i+3];
$dbuser=$archivo[$i+4];
$table=$archivo[$i+5];

$archivo1 = file("dbconvert.dat");
$lineas1 = count($archivo1);
$i1=0;
$server1 = $archivo1[$i1];
$port1=$archivo1[$i1+1];
$database1=$archivo1[$i1+2];
$dbpass1=$archivo1[$i1+3];
$dbuser1=$archivo1[$i1+4];
$table1=$archivo1[$i1+5];

$field1= "unicenso";
$field2= "nomunidadcenso";
$field3= "usercenso";
$field4= "dotcamacenso";
$field5= "rolusercenso";
$field6= "ingresototalcenso";
$field7= "ingresoscenso";
$field8= "ingresosxcti";
$field9= "ingresocontrol";
$field10= "egresototalcenso";
$field11= "altacenso";
$field12= "defuncioncenso";
$field13= "egresosxcti";
$field14= "egresocontrol";
$field15= "pacientediacenso";
$field16= "camaocupcenso";
$field18= "camadispcenso";
$field17= "camalibcenso";
$field19= "ipcenso";
$field0= "fechacensal";
$field21= "fechacenso";
$field22= "horacenso";
$field23= "validado";
$field24= "num_err";
$field25= "num_err1";
$field26= "num_err2";
$field27= "estadacenso";
$field28= "identifica";
$field29= "num_err3";
$field30= "menor6";
$field31= "datacontrol";
$field32= "ctiunidad";

HTML

$query1 = "SELECT * FROM $table ORDER BY fechacenso";

$link=pg_connect("host=$server port=$port dbname=$database user=$dbuser password=$dbpass");
if (!$link){
echo "<h2 align='center'>ERROR: Imposible establecer conexión con el servidor "."</h2>";
exit;
}

$result1=pg_query($link,$query1);
if (!$result1){
echo "<h2 align='center'>ERROR: Imposible establecer conexión </h2>";
exit;
}

$link1=pg_connect("host=$server1 port=$port1 dbname=$database1 user=$dbuser1 password=$dbpass1");

$query2="INSERT INTO $table1 (usercenso, unicenso, nomunidadcenso, fechacensal, fechacenso, horacenso,ingresototalcenso, ingresoscenso, ingresosxcti, egresototalcenso, altacenso, defuncioncenso, egresosxcti, pacientediacenso, camaocupcenso, camadispcenso, camalibcenso, estadacenso, menor6, datacontrol, ctiunidad, dia, mes, anio) VALUES ('$faux3','$faux1','$faux2','$faux21','$faux21','$faux22','$faux6', '$faux7', '$faux8','$faux10', '$faux11','$faux12','$faux13','$faux15','$faux16','$faux18','$faux17','$faux27', '$faux30', '$faux31', '$faux32', '$df', '$mf', '$af')";

$ResultQuery1 =pg_fetch_array($result1);
do{

//asignamos a variables los campos a transferir a la base final
$separar= explode("/",$ResultQuery1[$field0]);
$df=$separar[0]; //dia final
$mf=$separar[1]; //mes final
$af=$separar[2]; //año final
$auxdecha=mktime(0,0,0,$mf,$df,$af);
$faux0=date("Y-m-d",$auxdecha);

//$faux0=$ResultQuery1[$field0]; //fechacensal
$faux1=$ResultQuery1[$field1]; //unidad
$faux2=$ResultQuery1[$field2]; //nombre unidad
$faux3=$ResultQuery1[$field3]; //usuario unidad
$faux6=$ResultQuery1[$field6]; //ingresos totales
$faux7=$ResultQuery1[$field7]; //ingresos
$faux8=$ResultQuery1[$field8]; //ingresoso x cti
$faux10=$ResultQuery1[$field10]; //egresos totales
$faux11=$ResultQuery1[$field11]; //altas
$faux12=$ResultQuery1[$field12]; //defunciones
$faux13=$ResultQuery1[$field13]; //egresos x cti
$faux15=$ResultQuery1[$field15]; //pacientes dia
$faux16=$ResultQuery1[$field16]; //c ocupadas
$faux17=$ResultQuery1[$field17]; //c libres
$faux18=$ResultQuery1[$field18]; //c disponibles
$faux21=$ResultQuery1[$field21]; //fecha de ingresado el censo
$faux27=$ResultQuery1[$field27]; //dias estadia
$faux22=$ResultQuery1[$field22]; //hora censo
$faux30=$ResultQuery1[$field30]; //defunciones de menor
$faux31=$ResultQuery1[$field31]; //numero de control
$faux32=$ResultQuery1[$field32]; //si tiene cti o no

print $faux21;
echo "<br>";
$result2=pg_query($link1,$query2);
}while($ResultQuery1 = pg_fetch_array($result1));

if(pg_affected_rows($result2)){

html
}else{
html
?>

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message listapostgres 2006-08-15 17:48:53 Re: datestyle
Previous Message Leonel Nunez 2006-08-15 17:19:50 Re: Postgres Client install [DBD-Pg-1.01]