From: | "anuj" <Anuj(at)in-control(dot)de> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Cc: | <pgsql-general-owner(at)hub(dot)org> |
Subject: | Return PGresult |
Date: | 2000-07-20 07:28:49 |
Message-ID: | NEBBICAAMKOEBEPFMFPBGEJECBAA.Anuj@in-control.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
PGresult is a structure.
I want to return PGresult pointer.(Code is given below.)
Is this possible ? if yes , please give me the solution.
Thanks in Advance.
Anuj
===========================
/* tempdb=>create table tbltemp (id int4, name varchar(30)); */
#include <stdio.h>
#include <pgsql/libpq-fe.h>
main()
{
int totalrec;
PGresult *resu;
dbQuery("tempdb","select * from tbltemp",&totalrec,resu);
printf("\n The total rec = %i\n", totalrec);
printf(" The total rec = %i\n", PQntuples(resu));
} /* End of main */
dbQuery(char * dbName, char *sqlstatement , int *totalrec,PGresult *res)
{
PGconn *conn;
char fullsql[500];
conn = PQsetdb(NULL, NULL, NULL, NULL, dbName);
res = PQexec(conn, "BEGIN");
PQclear(res);
strcpy(fullsql , "DECLARE mycursor CURSOR FOR ");
strcat(fullsql,sqlstatement);
res = PQexec(conn, fullsql);
PQclear(res);
res = PQexec(conn, "FETCH ALL in mycursor");
*totalrec = PQntuples(res);
}
===========================
Out put :
$
The total rec = 2 // This result is right.
The total rec = 0 // The same result is not showing.
$
From | Date | Subject | |
---|---|---|---|
Next Message | Xavier ZIMMERMANN | 2000-07-20 07:42:25 | 8Ko limitation |
Previous Message | Tom Lane | 2000-07-20 06:55:48 | Re: Query problem - explicit casts |