Re: pg_query and COPY in transaction
| From: | Chris | Date: | Wed, 19 Jul 2006 00:36:17 +0000 |
| Subject: | Re: pg_query and COPY in transaction | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-239564@lists.php.net to get a copy of this message | ||
Luis Magaña wrote:
I have the following code: pg_query($conn,"BEGIN TRANSACTION;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/DELETE FROM codigo_postal; COPYcodigo_postal(codigo_postal,asentamiento,tipo_asentamiento,municipio,estado) FROM '$tmpfname2' DELIMITER '|';COMMIT");