Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [206.210.65.6]) by hub.org (8.9.2/8.9.1) with ESMTP id KAA91352; Mon, 8 Mar 1999 10:48:12 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id KAA06487; Mon, 8 Mar 1999 10:47:38 -0500 (EST) To: Michael Meskes cc: pgsql-interfaces@postgreSQL.org Subject: Re: [INTERFACES] Counting updates with libpq In-reply-to: Your message of Mon, 8 Mar 1999 08:46:47 +0100 <19990308084647.C227@gmx.net> Date: Mon, 08 Mar 1999 10:47:38 -0500 Message-ID: <6485.920908058@sss.pgh.pa.us> From: Tom Lane Michael Meskes writes: >> No. PQntuples() is the number of rows in the returned result. It will >> always be zero if the SQL command was not SELECT (or FETCH). > I'm afraid this is incorrect. I tried it on an insert (via exec sql execute > immediate) and it got the correct result. No, I'm afraid *you* are incorrect: a test program like res = PQexec(conn, "INSERT INTO test SELECT * FROM test"); if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "INSERT command failed\n"); PQclear(res); exit_nicely(conn); } printf("INSERT result PQntuples = %d\n", PQntuples(res)); printf("INSERT result PQcmdTuples = %s\n", PQcmdTuples(res)); produces the expected results (ntuples = 0, cmdTuples = number of inserted rows) for either variant of INSERT. It seems likely that ecpg is interposing some additional behavior not seen in bare libpq, although I'm at a loss to guess what. Surely ecpg wouldn't be trying to implicitly fetch the inserted rows? regards, tom lane