Incremental queries?
Posted in 2005
Topics: Versions, Editions & End-of-Life
Running IDS 9.21.FC4. We would like our application to support incremental queries of a table. By this we mean that the application should allow a user to press a "Query" button and receive the first block of 'n' rows of a table based on an ORDER BY of the key column(s). The user should then be able to press a "Query Next" button and retrieve the next block of 'n' rows (based on the same ORDER BY clause). We don't want to retrieve all rows in the table and buffer them locally on the client because the table could be huge and if user doesn't want to see all of the rows then too much network traffic was generated. Have figured out the WHERE clause to make the "Query Next" happen based on values of last row previously retrieved. It has the following form: where (col1 > last_val1) or (col1 = last_val1 and col2 > last_val2) or (col1 = last_val1 and col2 = last_val2 and col3 > last_val3) (This expands based on the number of columns in the key.) The SQL statement for the initial "Query" has no WHERE clause. It only has an ORDER BY clause and it runs relatively fast. The "Query Next" SQL statement has the WHERE if the form shown above and it runs terribly slow. Any ideas on what we can do to speed it up? Is what we're trying to accomplish not practical with IDS 9.21? Thanks for any insights you can share. Roger Tomas Lucent Technologies
roger, you can program this if you are using 4GL (and I assume in EGL too). declare a cursor for your select statement open the cursor fetch the first n rows and display them when they click on "query next" then fetch the next n rows
I should have included more information about our application. It is a Microsoft Windows application that is written in C# and uses ADO.NET. I'm fully aware of cursors (a HOLD CURSOR would be just the ticket) but I'm not sure we have any such construct available through ADO.NET (although I'm not 100% sure about that). So I'm looking for some other strategy for querying individual blocks of rows. We are currently making use of the "SELECT FIRST n" syntax when we construct our SQL statement.