![]() The tape _id column is eight characters long. I've allocated three buffers one for each column in the table. In client3a.c, I select all columns (and all rows) from the tapes table. Printf( "%s - %-40s - %s\n", tape_id, title, duration ) While( fetch( tape_id, title, duration ) != END_OF_TUPLES ) This might be a good point to see an example:Ĭonnection = connectdb( argv ? argv : "" ) ![]() If you aren't interested in the value of a column, you can pass a NULL pointer. You must pass one pointer for each column returned by the query. Each argument should point to a buffer large enough to hold the corresponding field from the result set. When you call fetch(), you pass a list of pointers. If the query returns zero rows, the first call to fetch() will return END_OF_TUPLES. When the result set is exhausted, fetch() will return END_OF_TUPLES. The first row returned is row 0, the second row is row 1, and so on. The fetch() function returns the index of the row that you just fetched. Here is the function prototype for fetch(): ![]() If you are reasonably sure that your query succeeded, you can use the fetch() function to retrieve a single row from the result set. libpgeasy provides a number of functions for dealing with a result set?of course, you can use any of the libpq functions as well. This is the same data structure you saw in the previous chapter?it represents the result set of the query.Īfter you have executed a command, you will need to process the result set. Notice that doquery() does not expect a PGconn *?libpgeasy can deal with only a single database connection and it implicitly uses the one returned by connectdb(). To execute a SQL command, you call the doquery() function. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |