Guest User

Untitled

a guest
Apr 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. # Get the rows, handling any offset and/or limit stipulated
  2. if scrollableCursor then
  3. rRows = nil
  4. # scrollableCursor == true => offset > 0
  5. if stmt.fetch_scroll(ODBC::SQL_FETCH_ABSOLUTE, offset)
  6. rRows = limit > 0 ? stmt.fetch_many(limit) : stmt.fetch_all
  7. end
  8. else
  9. rRows = limit > 0 ? stmt.fetch_many(offset + limit) : stmt.fetch_all
  10. # Enforce OFFSET
  11. if offset > 0 then
  12. if rRows && rRows.length > offset then
  13. rRows.slice!(0, offset)
  14. else
  15. rRows = nil
  16. end
  17. end
  18. # Enforce LIMIT
  19. if limit > 0 && rRows && rRows.length > limit then
  20. rRows.slice!(limit..(rRows.length-1))
  21. end
  22. end
Add Comment
Please, Sign In to add comment