Received: from mail.ocol.com (IDENT:qmailr@mail.ocol.com [204.244.123.209]) by hub.org (8.9.3/8.9.3) with SMTP id WAA54582 for ; Fri, 18 Jun 1999 22:53:32 -0400 (EDT) (envelope-from kvp@ocol.com) Received: (qmail 15316 invoked from network); 19 Jun 1999 03:11:21 -0000 Received: from fsj3-6.ocol.com (HELO ocol.com) (root@204.244.123.47) by mail.ocol.com with SMTP; 19 Jun 1999 03:11:21 -0000 Sender: root Message-ID: <376B06C7.CE39D054@ocol.com> Date: Fri, 18 Jun 1999 19:56:07 -0700 From: Ken Plumbly Reply-To: kvp@ocol.com Organization: Aurora Communications X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5-15 i586) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: ordered output under c/libpq Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I queried this a couple of days ago and got an excellent response, The software works, the query is sent, but the printed order the same order in which the data was entered. So either my query is being chopped at the order by statement, or I'm not printing it correctly. now, I wonder if anyone more experienced at bot c and postgres can see what I am doing wrong here: (I'm a novice so bear with me:-)) C code: sprintf(query, "select * from %s order by %s", table, PQfname(result, 0)); fprintf(cgiOut, "
%s

\n", query); res = PQexec(conn, query); if((!res) || (PGRES_TUPLES_OK != PQresultStatus(res))) { fprintf(cgiOut, "
Error Sending Query

Detailed Report: %s
\n", PQerrorMessage(conn)); PQfinish(conn); fprintf(cgiOut, "\n"); fprintf(cgiOut, "\n"); exit(1); } for (i = PQntuples(res)-1; i >= 0; i--) { for(y = 0; y < z; y++) { fprintf(cgiOut, "%s\n", PQgetvalue(result, i, y)); } fprintf(cgiOut, "\n"); } fprintf(stdout, "\n"); fprintf(cgiOut, "\n"); fprintf(cgiOut, "\n"); fprintf(cgiOut, "\n"); exit(0); } Debugging File: read_pg_options: syslog=2,verbose=2,query=4 debug info: User = root RemoteHost = localhost RemotePort = 0 DatabaseName = oilfield Verbose = 3 Noversion = f timings = f dates = Normal bufsize = 64 sortmem = 512 query echo = f InitPostgres StartTransactionCommand query: select * from companies ProcessQuery CommitTransactionCommand StartTransactionCommand query: select * from companies order by comp_name ProcessQuery CommitTransactionCommand proc_exit(0) [#0] shmem_exit(0) [#0] exit(0) Am I blind or, just plain tired from too many late nights? ;-) Ken kvp@ocol.com