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");
> 
> It is suppoused as I understand it, that if an error occurs on the copy
> statement, then the codigo_postal table should still have all of the
> previous records. Actually I've tested it within psql and it works as
> expected.
> 
> However, the shown code does not. If an error occurs on the copy
> transaction, the data on the table gets deleted.
> 

The above code looks like it should work.  I have done similar stuff in
the past.

A useful trick that you might like to try is that PHP automatically will
automatically wrap a query with multiple parts into a transaction for
you.  I believe it will also do slightly more advanced clean up of the
commit/rollback than the default.  Doing it this way might work better
for you.


David

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

Reply via email to