Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. getting data in parts

getting data in parts

Scheduled Pinned Locked Moved Database
databasehelpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ArchaBhandare
    wrote on last edited by
    #1

    I wanted to know if it is possible to get the data in parts. I mean my application has many records in the table, so for a sql query like select * from table, there is lots of records to be read from the ResultSet. Is there any query like select (first 100) * from table then select (next 100) * from table . . . something like this ? please help

    P E 2 Replies Last reply
    0
    • A ArchaBhandare

      I wanted to know if it is possible to get the data in parts. I mean my application has many records in the table, so for a sql query like select * from table, there is lots of records to be read from the ResultSet. Is there any query like select (first 100) * from table then select (next 100) * from table . . . something like this ? please help

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      select top 100 records from table where id > @id The first time in, pass in an @id of 0. Next time, pass in the maximum id of the previous results.

      Deja View - the feeling that you've seen this post before.

      C 1 Reply Last reply
      0
      • A ArchaBhandare

        I wanted to know if it is possible to get the data in parts. I mean my application has many records in the table, so for a sql query like select * from table, there is lots of records to be read from the ResultSet. Is there any query like select (first 100) * from table then select (next 100) * from table . . . something like this ? please help

        E Offline
        E Offline
        Elina Blank
        wrote on last edited by
        #3

        SELECT * FROM Table WHERE RowNumber Between @FirstRow AND @EndRow

        Sincerely, Elina Life is great!!! Enjoy every moment of it! :-O

        A 1 Reply Last reply
        0
        • P Pete OHanlon

          select top 100 records from table where id > @id The first time in, pass in an @id of 0. Next time, pass in the maximum id of the previous results.

          Deja View - the feeling that you've seen this post before.

          C Offline
          C Offline
          Chandman
          wrote on last edited by
          #4

          That's a clever idea. But it does not work all the time: Say you have to sort on a field - then the id's gets shuffled. For example go to dell's outlet listings page: http://outlet.us.dell.com/ARBOnlineSales/topics/global.aspx/arb/online/en/InventorySearch?c=us&cs=22&l=en&lob=DIM&MODEL_DESC=XPS%20210&s=dfh[^] I wonder if they're doing the same thing here. Or are they just pulling all the record at once and doing the paging and sorting thing at the webpage level.

          P 1 Reply Last reply
          0
          • C Chandman

            That's a clever idea. But it does not work all the time: Say you have to sort on a field - then the id's gets shuffled. For example go to dell's outlet listings page: http://outlet.us.dell.com/ARBOnlineSales/topics/global.aspx/arb/online/en/InventorySearch?c=us&cs=22&l=en&lob=DIM&MODEL_DESC=XPS%20210&s=dfh[^] I wonder if they're doing the same thing here. Or are they just pulling all the record at once and doing the paging and sorting thing at the webpage level.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            You are right that it is a simplistic solution. I find that it fits a lot of cases though. A lot of time when you sort/shuffle the id's around, this is done by retrieving the data in one go and performing the sorting/shuffling on the server.

            Deja View - the feeling that you've seen this post before.

            1 Reply Last reply
            0
            • E Elina Blank

              SELECT * FROM Table WHERE RowNumber Between @FirstRow AND @EndRow

              Sincerely, Elina Life is great!!! Enjoy every moment of it! :-O

              A Offline
              A Offline
              ArchaBhandare
              wrote on last edited by
              #6

              I still didnt get what to do How should the above command be written as ? my table name is 'orders' and there are only 2 fields in that 'ORDERID' and 'ITEMDESIRED' There is no primary key as such. Yes I can make 'ORDERID' the Primary key though. What should be the '@FirstRow' and '@EndRow' values be?? or should I write them just like that. Please help, its urgent. I am using the ojdbc14.jar to connect to the Oracle 10g database. I read somewhere about the LIMIT and OFFSET command, but tried it in Oracle SQL* Plus and saw that it does not work. Also it gave the same exception when tried to run the command through my Java program. The command I ran is select * from orders limit 10; and the Exception I got is ORA-00933: SQL command not properly ended

              E 1 Reply Last reply
              0
              • A ArchaBhandare

                I still didnt get what to do How should the above command be written as ? my table name is 'orders' and there are only 2 fields in that 'ORDERID' and 'ITEMDESIRED' There is no primary key as such. Yes I can make 'ORDERID' the Primary key though. What should be the '@FirstRow' and '@EndRow' values be?? or should I write them just like that. Please help, its urgent. I am using the ojdbc14.jar to connect to the Oracle 10g database. I read somewhere about the LIMIT and OFFSET command, but tried it in Oracle SQL* Plus and saw that it does not work. Also it gave the same exception when tried to run the command through my Java program. The command I ran is select * from orders limit 10; and the Exception I got is ORA-00933: SQL command not properly ended

                E Offline
                E Offline
                Elina Blank
                wrote on last edited by
                #7

                The example query I gave works fine for SQL Server 2005 @FirstRow = row, from which you want to start getting the results @EndRow = last row of your results In your case, for exapmple, it can be

                SELECT OrderID,ItmDesired
                FROM ORDERS
                WHERE OrderID BETWEEN 5 AND 25

                OR, if this does not work, in your db, try:

                SELECT OrderID,ItmDesired
                FROM ORDERS
                WHERE OrderID > 5 AND ORDERID < 25

                Sincerely, Elina Life is great!!! Enjoy every moment of it! :-O

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups