Thread: libpq problem with inserts

libpq problem with inserts

From
"Kevin Sorensen"
Date:
i have been reading most of the night trying to figure this out, and it
may be just because i am tired that i missed something but here is the
problem i am having:

i am running a loop inserting several items into a table something kind
of similar as below, but more complicated. However, when i print the sql
strings, everything prints out and works fine, however, when i try to
insert them into the database, only some of them get inserted. i can say
that i am quite unfamiliar with libpq, but this one perl script is about
the only thing i have done with it, and it is for a cronjob. usually i use
php and have no problems. anyways, if anyone knows the answer or any ideas,
i would appreciated it.

postgresql v.7.0.0
rh linux 6.1

while ($i < 50) {
$blah1 = PQexec($conn, "INSERT INTO invoice_desc VALUES ('$val1', '$val2',
'$val3', '$val4');");
$blah2 = PQexec($conn, "INSERT INTO invoice_desc VALUES ('$val11', '$val12',
'$val13', '$val14');");
$blah3 = PQexec($conn, "INSERT INTO invoice_desc VALUES ('$val21', '$val22',
'$val23', '$val24');");
$blah4 = PQexec($conn, "INSERT INTO invoice_desc VALUES ('$val31', '$val32',
'$val33', '$val34');");
$i++;
}

my only guess is that some of the inserts are taking longer or something,
and it is just dropping them or something.


Re: libpq problem with inserts

From
Tom Lane
Date:
"Kevin Sorensen" <kevin@pcxcess.com> writes:
> i am running a loop inserting several items into a table something kind
> of similar as below, but more complicated. However, when i print the sql
> strings, everything prints out and works fine, however, when i try to
> insert them into the database, only some of them get inserted.

Any quote marks or backslashes in the data you're inserting?

            regards, tom lane

RE: libpq problem with inserts

From
"Kevin Sorensen"
Date:
sorry, no. as for the data that i am inserting, most of it is just numbers
as the script is to run invoicing on customers in the database. and it runs
through the loop several times, and just leaves out some of the entries when
looping through. i was reading about the synchronous, asynchronous methods
in libpq, but it just confused me more. heh, no sleep for me last night,
maybe
that is it.

kevin

-----Original Message-----
From: pgsql-general-owner@hub.org [mailto:pgsql-general-owner@hub.org]On
Behalf Of Tom Lane
Sent: Friday, September 08, 2000 9:12 AM
To: Kevin Sorensen
Cc: pgsql-general@hub.org
Subject: Re: [GENERAL] libpq problem with inserts


"Kevin Sorensen" <kevin@pcxcess.com> writes:
> i am running a loop inserting several items into a table something kind
> of similar as below, but more complicated. However, when i print the sql
> strings, everything prints out and works fine, however, when i try to
> insert them into the database, only some of them get inserted.

Any quote marks or backslashes in the data you're inserting?

            regards, tom lane