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.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to