pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedordered output under c/libpq
2+ messages / 1 participants
[nested] [flat]
* ordered output under c/libpq
@ 1999-06-19 02:56 Ken Plumbly <kvp@ocol.com>
0 siblings, 0 replies; 2+ messages in thread
From: Ken Plumbly @ 1999-06-19 02:56 UTC (permalink / raw)
To: pgsql-interfaces
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, "<CENTER>%s</CENTER><BR>\n",
query);
res = PQexec(conn, query);
if((!res) || (PGRES_TUPLES_OK !=
PQresultStatus(res)))
{
fprintf(cgiOut, "<BR><CENTER>Error
Sending Query</CENTER><BR><CENTER>Detailed Report: %s</CENTER>\n",
PQerrorMessage(conn));
PQfinish(conn);
fprintf(cgiOut, "</BODY>\n");
fprintf(cgiOut, "</HTML>\n");
exit(1);
}
for (i = PQntuples(res)-1; i >= 0; i--)
{
for(y = 0; y < z; y++)
{
fprintf(cgiOut, "<TD>%s</TD>\n",
PQgetvalue(result, i, y));
}
fprintf(cgiOut, "<TR>\n");
}
fprintf(stdout, "</TABLE>\n");
fprintf(cgiOut, "</CENTER>\n");
fprintf(cgiOut, "</BODY>\n");
fprintf(cgiOut, "</HTML>\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
^ permalink raw reply [nested|flat] 2+ messages in thread
* RE: Ordered output under c/libpq
@ 1999-06-19 03:50 Ken Plumbly <kvp@ocol.com>
0 siblings, 0 replies; 2+ messages in thread
From: Ken Plumbly @ 1999-06-19 03:50 UTC (permalink / raw)
To: pgsql-interfaces
Hi All, well, I resolved my own problem (You know the old saying about
"if I had any brains I'd be dangerous ;-))
I had a misnamed variable, so once I renamed it, the ordered by
worked.
Thanks for the answers I did get.
Ken
kvp@ocol.com
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-06-19 03:50 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-06-19 02:56 ordered output under c/libpq Ken Plumbly <kvp@ocol.com>
1999-06-19 03:50 RE: Ordered output under c/libpq Ken Plumbly <kvp@ocol.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