ODBC iterate table without storing in memory
I need to have a way to iterate through a database table without actually storing it in memory anywhere. I want to essentially read through the rows like an input iterator.
I've tried using cursors with a select statement (se开发者_如何学JAVAlect * from table_name), but this retrieves the entire table and feeds it back to be one row at a time. So this solution is no good. Instead, I need it to only feed me each row as I ask for it.
Any suggestions are greatly appreciated.
Thanks!
You'll just want to use a forward only cursor. Your DB will need to support this. For detials, see MSDN's How to: Use Cursors.
If you're using SQL Server, you can use a Fast Forward-Only Cursor, which provides extra benefits.
精彩评论