Re: which function should i invoke to create a table and insert tuples?

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: which function should i invoke to create a table and insert tuples?
Дата
Msg-id 4BF1D391.7000109@hogranch.com
обсуждение исходный текст
Ответ на Re: which function should i invoke to create a table and insert tuples?  (sunpeng <bluevaley@gmail.com>)
Список pgsql-general
sunpeng wrote:
> it's in source codes,actually i'm writting codes in postgresql source
> codes,just to verify some of my ideas. C language is used.

you would pass the SQL statements to do what you want to the various
libpq library functions...


something like...

    PGconn *conn;
    PGresult *res;

    conn = PQconnectdb("dbname=mydatabase");
    if (PQstatus(conn) != CONNECTION_OK) {
    fprintf(stderr, "Connection to database failed: %s",
    PQerrorMessage(conn));
    exit_nicely(conn);
    }

    res = PQexec(conn, "create table test (id serial, num int, value
    text);");
    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
    fprintf(stderr, "BEGIN command failed: %s", PQerrorMessage(conn));
    PQclear(res);
    exit_nicely(conn);
    }
        ...



most folks would probably put the PQexec() and status tests into a
function to simplify things.


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

Предыдущее
От: sunpeng
Дата:
Сообщение: Re: which function should i invoke to create a table and insert tuples?
Следующее
От: John R Pierce
Дата:
Сообщение: [Fwd: failure notice]