You can use the mysql_stmt_attr_set() function in the C API to implement cursor functionality on the server side, but it has certain usage limitations.
Server-side cursors allow you to generate result sets on the server side, but only the rows requested by the client are transmitted to the client. For example, if a client executes a query that only needs the first row of data, the remaining rows are not transmitted to the client.
Additionally, cursors have the following usage limitations:
Cursors are read-only and cannot be used to update rows. Therefore, the
UPDATE WHERE CURRENT OFandDELETE WHERE CURRENT OFstatements are not supported.Cursors are not held after a commit. That is, they are not kept open after a commit.
Cursors are insensitive.
Cursors are not scrollable.
Cursors cannot be named. You can obtain the cursor ID by using a statement handle.
Each prepared statement can open only one cursor. The number of cursors is the same as the number of prepared statements.
If a statement that generates a result set is not supported in prepared mode, you cannot use a cursor for that statement. This includes statements such as
CHECK TABLE,HANDLER READ, andSHOW BINLOG EVENTS.
