Re: Incremental queries?
Posted in 2005
Hi,
I'm not that much into embedded SQL, but my understanding
always was, that this is exactly what you do with a cursor.
Cursors are available with ESQL/C, surely with ESQL/Cobol
and maybe with 4GL. You prepare your normal SQL statement
(with whatever complicated ORDER BY, WHERE clauses, etc.)
and then you open a cursor for this. With this cursor you can get
as many rows as you want (one by one) and display them.
When a user wants more rows (by using your programmed
"Next" command), you simply continue getting more rows with
the same cursor and display them again. This way you can go
on until the user has had enough. Then you close the cursor.
I think this is how e.g. dbaccess handles it (check out the query
menu where there is the "Next" functionality) ...
TIA,
Martin
--
Martin Fuerderer
IBM Informix Development Munich, Germany
Information Management
owner-informix-list@iiug.org wrote on 13.06.2005 23:40:37:
> 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
sending to informix-list