Re: Using SELECT inside a COPY transaction with PHP

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Fitzpatrick <robert(at)webtent(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using SELECT inside a COPY transaction with PHP
Date: 2004-07-21 15:03:21
Message-ID: 8773.1090422201@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Robert Fitzpatrick <robert(at)webtent(dot)com> writes:
> I tried posting this to PHP-DB list, but no answers since yesterday. I'm
> thinking it is not possible, but just trying to confirm. I am using
> pg_exec($dbh, "COPY sometable FROM stdin USING DELIMITERS"). Once this
> the connectino is made and this line has been issued, my script begins
> analyzing each line of the CSV file and needs to do a SELECT statement
> using some of the fields in the line to find other related data before
> calling pg_end_copy($dbh), which syncs the data. Can another pg_exec
> call be made for a SELECT statement before the COPY is over? My script
> seems to hang at the point of the first SELECT.

You'd have to open a second database connection to issue the SELECT on.
Your first one is tied up doing the COPY (the connection protocol is
not multi-threaded or anything like that).

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Markus Wollny 2004-07-21 15:03:58 Re: tsearch2, ispell, utf-8 and german special characters
Previous Message wespvp 2004-07-21 14:54:50 Locking with foreign key constraints