User Answers

I think 

set booksRS = ##class(%ResultSet).%New("Library.Book,BooksLoaned")

should be 

set booksRS = ##class(%ResultSet).%New("Library.Book:BooksLoaned")

Might help if you change it to

ClassMethod MyMethod(pFilePath as %String)

You will either need to use a scrollable result set (%Library.ScrollableResultSet) or execute the query again.

I've seen this happen when the hard drive is full

This would also be useful for reading and writing excel files.