Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [206.210.65.6]) by hub.org (8.9.3/8.9.1) with ESMTP id KAA13346 for ; Tue, 20 Apr 1999 10:36:13 -0400 (EDT) (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 KAA13839; Tue, 20 Apr 1999 10:35:30 -0400 (EDT) To: "Anna Langer" cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Questions about embedded-sql! In-reply-to: Your message of Tue, 20 Apr 1999 02:18:11 PDT <19990420091812.48659.qmail@hotmail.com> Date: Tue, 20 Apr 1999 10:35:30 -0400 Message-ID: <13837.924618930@sss.pgh.pa.us> From: Tom Lane "Anna Langer" writes: > We are having some problems with writing embedded-sql. We want to > write like this but it doesn't work. test1 is our table in our > database. > res = PQexec(conn, "select * from test1"); > if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) > { > fprintf(stderr, "DECLARE CURSOR command failed\n"); > ... A successful SELECT query will return status PGRES_TUPLES_OK, not PGRES_COMMAND_OK. You probably adapted this code from an example that was executing a command that cannot return tuples (DECLARE CURSOR, no doubt?). PGRES_COMMAND_OK is the right thing in that case. You should read the documentation and sample programs for libpq ... regards, tom lane