Postgres Insert return codes

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi group -

I am collecitng form data and inserting into multiple tables with a
foregin key.

Can someone tell me why if the insert fails on the 1st insert, then all
the other inserts also return a FAILURE return code :

$delegatecontent = array( "id" => $idnum, "language" => $insertlang );
$delegateres = pg_insert($conn, 'delegate', $delegatecontent);
if ($delegateres) { // echo "success del";
     } else {
             echo "<b>INSERT Failed!

$meetingcontent = array( "fk_meetingsid" => $idnum, "meetingsga" =>
$meetingga );
$meetingres = pg_insert($conn, 'meetings', $meetingcontent);
 if ($meetingres) { // echo "success meetings";
     } else {
             echo "<b>INSERT Failed!

What is syntactically wrong with this code ?  


Re: Postgres Insert return codes

Syl wrote:
Quoted text here. Click to load it

Do you mean that after performing:

Quoted text here. Click to load it

This also returns also false, while it should be true (you verified it
Quoted text here. Click to load it

I'm not aware on anthything wrong with the syntax (never used pg_insert()
though), but why not:

if (pg_insert($conn, 'delegate', $delegatecontent)) {
    // echo "success del";
} else {
    echo "<b>INSERT Failed!

BTW: User comment on
ANDYCHR17 ***********
05-May-2006 11:50
- Function was returning false until I passed the PGSQL_DML_EXEC option.

So, try  pg_insert($conn, 'delegate', $delegatecontent, PGSQL_DML_EXEC);

Rik Wasmus

Re: Postgres Insert return codes

Hi Rik - Yes, I printed out the statment to screen, and ran it from the
command line and all works fine!. :-(

Site Timeline