Re: pg_query and COPY in transaction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Luis Magaña wrote:
I have the following code:

pg_query($conn,"BEGIN TRANSACTION;
          DELETE FROM codigo_postal;
          COPY
codigo_postal(codigo_postal,asentamiento,tipo_asentamiento,municipio,estado)
FROM '$tmpfname2' DELIMITER '|';
          COMMIT");

Separate them out as a first step:

$result = pg_query("begin");
if (!$result) {
  echo "error at line " . __LINE__ . ": " . pg_last_error() . "<br/>";
}

$result = pg_query("delete from codigo_postal;");
if (!$result) {
  echo "error at line " . __LINE__ . ": " . pg_last_error() . "<br/>";
}

$result = pg_query("COPY codigo_postal(codigo_postal,asentamiento,tipo_asentamiento,municipio,estado) FROM '$tmpfname2' DELIMITER '|';");
if (!$result) {
  echo "error at line " . __LINE__ . ": " . pg_last_error() . "<br/>";
}

$result = pg_query("commit");
if (!$result) {
  echo "error at line " . __LINE__ . ": " . pg_last_error() . "<br/>";
}

and see if you get any errors.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux