Handling data in libpq
От | am@fx.ro |
---|---|
Тема | Handling data in libpq |
Дата | |
Msg-id | 20021019132352.A419@coto обсуждение исходный текст |
Ответ на | ANN: EMS PostgreSQL Utils released! (dkovt@ems-hitech.com (Danya Kovtunowitch)) |
Ответы |
Re: Handling data in libpq
|
Список | pgsql-interfaces |
Hello everyone! 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 tableis 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 )? Thanks, Adrian Maier (am@fx.ro)
В списке pgsql-interfaces по дате отправления: