pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: [SQL] Questions about embedded-sql!
2+ messages / 2 participants
[nested] [flat]
* Re: [SQL] Questions about embedded-sql!
@ 1999-04-20 13:30 Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
1999-04-20 14:24 ` Re: [INTERFACES] Re: [SQL] Questions about embedded-sql! Maarten Boekhold <boekhold@tibco.com>
0 siblings, 1 reply; 2+ messages in thread
From: Gene Selkov, Jr. @ 1999-04-20 13:30 UTC (permalink / raw)
To: Anna Langer <anna_langer@hotmail.com>; pgsql-interfaces
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [INTERFACES] Re: [SQL] Questions about embedded-sql!
1999-04-20 13:30 Re: [SQL] Questions about embedded-sql! Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
@ 1999-04-20 14:24 ` Maarten Boekhold <boekhold@tibco.com>
0 siblings, 0 replies; 2+ messages in thread
From: Maarten Boekhold @ 1999-04-20 14:24 UTC (permalink / raw)
To: Gene Selkov, Jr. <selkovjr@mcs.anl.gov>; +Cc: Anna Langer <anna_langer@hotmail.com>; pgsql-interfaces
> Always check conn->errorMessage in case of errors to find what causes them
Check this using PQerrorMessage(conn). You're not supposed to access the
PGconn datastructure directly, its implementation might change in the
future, PQerrorMessage() will mask these changes.
Maarten
--
Maarten Boekhold, boekhold@tibco.com
TIBCO Finance Technology Inc.
The Atrium
Strawinskylaan 3051
1077 ZX Amsterdam, The Netherlands
tel: +31 20 3012158, fax: +31 20 3012358
http://www.tibco.com
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-04-20 14:24 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-04-20 13:30 Re: [SQL] Questions about embedded-sql! Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
1999-04-20 14:24 ` Maarten Boekhold <boekhold@tibco.com>
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