Received: from antares.mcs.anl.gov (mcs.anl.gov [140.221.9.6]) by hub.org (8.9.3/8.9.1) with SMTP id KAA10161 for ; Tue, 20 Apr 1999 10:30:04 -0400 (EDT) (envelope-from selkovjr@xnet.com) Received: from xnet.com (selkovjr@selkovjr.xnet.com [205.243.141.67]) by antares.mcs.anl.gov (8.6.10/8.6.10) with ESMTP id JAA28430; Tue, 20 Apr 1999 09:29:58 -0500 Message-Id: <199904201429.JAA28430@antares.mcs.anl.gov> To: "Anna Langer" , pgsql-interfaces@postgreSQL.org From: "Gene Selkov, Jr." 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 09:30:02 -0400 Sender: selkovjr@xnet.com With the subject like this, you will get more help from the INTERFACES list. > Hi! > > 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"); > PQclear(res); > exit_nicely(conn); > } > PQclear(res); > > In the example that we have get this part from are they using CURSORS. > Do you have to use them? Does anybody know where we can find some > examples about embedded-sql in C or C++? Does anybody know where we > can find anyting about CURSOR? > > We really need some help!!!! > > Anna and Maria The piece you quoted does not look like embedded sql to me, but you're the boss ;-) It should, however work, if all of the following is true: 1. You have a running postmaster and it accepts connections from your client 2. The database you are connecting to exists and has the table test1 3. The connection whose handle you are referring to (conn) was established and you did not get any errors from it. Also, when sending a SELECT statement with libpq, you are supposed to check the result against PGRES_TUPLES_OK. You will use PGRES_COMMAND_OK to check the status of those commands that don't return any tuples, such as CREATE or INSERT. Always check conn->errorMessage in case of errors to find what causes them You don't have to use cursors, but that's about all you can do if your client must be able to page through lots of results. Now if you really meant using embedded sql, take a look at /whatever_is_your_postgres_source_dir/src/interfaces/ecpg/test --Gene