mysql c api interface: how to make bulk fetch : array of structures

216 views Asked by At

In ProC oracle, to get "bulk rows from a table(s) in one shot" ( without any for loop iteration in code) : we use Embedded sql calls to declare cursor to define a sql select statement . Then we used to make cursor open call and then finally we make a single fetch call from the cursor into a array of structure pointer in one shot. ( the array of structures are allocated earlier as per number of rows fetched earlier and structure is defined as per the select query field values ). So the bulk fetch is handled by the cursor defined and one single fetch call from application code.

Now, my requirement is to do same "bulk fetch (select) and assign in array of struct" in mySQL / mariaDB - I am going through the list of C apis, but still i cant find any such mechanism where i can do a bulk fetch and assign in array of structures in one shot. Can any one suggest me ?

1

There are 1 answers

1
danblack On

While the C API statements are for fetching a row, they do not always require a round trip to the server to retrieve the data.

The SQL statement results are retrieved into the net-buffer, which will resize to larger (max-packet-length if required.

So a loop isn't avoidable, however there is little cost in doing so. Increasing the default net buffer length will minimize the amount of round trip to server retrievals.

You may also be able to use the non-blocking API to process those rows that are available.