I have written a C program that:
- displays in a tabular form the data in a table
- allows inserts,deletes,updates, and user-defined filters('enter a query')
- uses libpq and ncurses.
The program is rather inefficient right now :
- In order to fetch the data, i call:
RecordSet = PQexec(conn,"select FIELD1,...,FIELDn,OID from TBL");
nRecords = PQntuples(RecordSet);
- when i need a specific tuple, i call :
PQgetvalue(RecordSet,crtRecord,field); for each field
I'm looking for a new approach regarding fetching the data.
Usage of cursors is probably the path to follow. I would be deeply
grateful to anyone who would share a bit of his/her experience:
- i assume the table has 50000 tuples
- what is better: to fetch one tuple at one time, or to fetch
a certain number of tuples (let's say 100).
- if i fetch 100 tuples, PQntuples returns 100? how do i know how
many rows has the table?
- i have the impression that keeping track of the tuple's index i
nside the RecordSet and the index inside the whole table is quite
tricky, but manageable. How do you guys handle this kind of situations?
- are there more examples that use cursors, except the ones in
docs ( in the libpq chapter )?
In response to
pgsql-interfaces by date
|Next:||From: Jeroen T. Vermeulen||Date: 2002-10-19 11:01:36|
|Subject: Re: Handling data in libpq|
|Previous:||From: Jeroen T. Vermeulen||Date: 2002-10-18 14:23:08|
|Subject: Re: PgDatabase, on heap construction results in SIGSEGV.|