Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Location
    New Delhi - India
    Posts
    22

    Unanswered: Selecting rows in chunk

    Hi,
    I have an sqlite table containing 1 million records. The rows get inserted and deleted randomly. During start -up of my application, I need to fill the database in my data structures. How can I pick up the rows in chunks of 10000. I dont want to delete the rows from sqlite table in this start up.

  2. #2
    Join Date
    Feb 2010
    Posts
    38
    I'm not sure if this is what you meant, but if you want to select the first 10000 rows in a table you could go with "SELECT * FROM table LIMIT 10000" and for the following 10000 rows "SELECT * FROM table LIMIT 10000 OFFSET 10000".

  3. #3
    Join Date
    Mar 2009
    Location
    New Delhi - India
    Posts
    22
    I want to do the below( Lets say the table has 10000 rows. I want to read all the rows in chunks) :

    Read 2000 rows
    increase some counter
    read next 2000 rows
    increase some counter .. and so on..

    I want to do this in a loop.
    Can it be done by changing values in limit and offset.

    Thanks

  4. #4
    Join Date
    Feb 2010
    Posts
    38
    I guess it can be done in a loop with variables for limit and offset, and maybe you need to count the rows first to know how much looping is required. I don't know how it handles errors when the offset is maxed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •