From: Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
To: Anna Langer <anna_langer@hotmail.com>
To: pgsql-interfaces@postgreSQL.org
Subject: Re: [SQL] Questions about embedded-sql!
Date: Tue, 20 Apr 1999 09:30:02 -0400
Message-ID: <199904201429.JAA28430@antares.mcs.anl.gov> (raw)
In-Reply-To: <19990420091812.48659.qmail@hotmail.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: selkovjr@mcs.anl.gov, anna_langer@hotmail.com
Subject: Re: [SQL] Questions about embedded-sql!
In-Reply-To: <199904201429.JAA28430@antares.mcs.anl.gov>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox