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.

wrapping an SQL question in a php function doesn't make it a php question. ;-)

$apps = array("apache", "mysql", "windows"); $i = 0;
while ($i++ < 100) printf("how do I install %s?\n", $apps[ rand(0,2) ]);

// I ran that code for a laugh a number of times - seems to a bias towards
// asking how to install windows... go figure on a php list.

> 
> I'm certainly lost on this one, is it a bug ?, am I doing something
> wrong ? (most likely I guess)

you are wrong. there is no ROLLBACK specified. I suggest you
do the queries one by one (i.e. one call to pg_query() for each statement)
and if the 'COPY' fails call a 'ROLLBACK'

disclaimer: I know nothing about PG as such - I mostly use Firebird;

> 
> Any help will be apprecciated.
> 
> PHP: 5.1.2
> PostgreSQL: 8.1.4
> Apache: 2.0.55
> Debian Linux with Kernel 2.6.16
> 
> 

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

Reply via email to