Re: [SQL] Questions about embedded-sql!

Поиск
Список
Период
Сортировка
От Gene Selkov, Jr.
Тема Re: [SQL] Questions about embedded-sql!
Дата
Msg-id 199904201429.JAA28430@antares.mcs.anl.gov
обсуждение исходный текст
Список 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

В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Peter Mount
Дата:
Сообщение: RE: [INTERFACES] Compiling jdbc for Linux and Solaris
Следующее
От: Maarten Boekhold
Дата:
Сообщение: Re: [INTERFACES] Re: [SQL] Questions about embedded-sql!