Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem with PQgetvalue

0 views
Skip to first unread message

Casey Barnes

unread,
May 31, 2003, 1:55:15 PM5/31/03
to
when i use PQgetvalue in a loop to print out all my entries in the table it
will only return every other entry. When i use PQprint it works fine though

the code is shown below:

sprintf(command, "SELECT * FROM log;");
SQLresult = PQexec(SQLconn, command);

num_tuples = PQntuples(SQLresult);
num_fields = PQnfields(SQLresult);

//PQprint(stdout, SQLresult, SQLprintOpt);
//printf("%d %d\n", num_tuples, num_fields);

for(i = 0; i < num_tuples; i++)
{
for(j = 0; j < num_fields; j++)
{
tempstring = 0;
tempstring = PQgetvalue(SQLresult, i, j);
printf("%s %d %d\n", tempstring, i, j);
strncat(tempstring, "\t", 1);
strcat(filestring, tempstring);
}
strncat(filestring, "\n", 1);
}
printf("%s", filestring);

//fprintf(plogFile, "Who\n");
}


the output looks like

2 4 13:58:33 169.226.2.230
BDF
2 4 13:58:43 169.226.2.230
Who


but should look like

2 3 4 2003-04-15 13:58:33 BDF:
169.226.2.22:/export/applications/mandrake7.0 52
169.226.2.230 /usr/bin/df -k BDF
2 3 4 2003-04-15 13:58:43 USERS: 3 169.226.2.230
who -q Who


0 new messages