Re: Simple SQL Question

Поиск
Список
Период
Сортировка
От Franco Bruno Borghesi
Тема Re: Simple SQL Question
Дата
Msg-id 1099678157.39887.15.camel@taz.oficina
обсуждение исходный текст
Ответ на Simple SQL Question  (Andras Kutrovics <n-drew@freemail.hu>)
Ответы Re: Simple SQL Question
Список pgsql-sql
wouldn't it be easier using offset & limit?: you always select from the table with an itemkey,location order by
clause.You save the current offset between requests, and for every request you re-execute the query with a different
offset.<br/><br /> If you still want to go with what you already have, you should keep the lastItemKey and
lastLocaltionvalues between requests, and your where clause should be something like:<br /> WHERE (itemKey=:lastItemKey
ANDlocation>:lastLocation) OR (itemKey>:lastItemKey)<br /><br /> hope it helps.<br /><br /> On Fri, 2004-11-05 at
13:54,Andras Kutrovics wrote: <blockquote type="CITE"><pre><font color="#737373"><i>Hi All! 

In one of my application, I would like to implement incremental
fetching. The problem is that I would like to run it
from a stateless application server, so I have to tell where
to begin fetching data. It is simple for a table which has single column
primary key, but causes difficulties (at least for me) in
a more-column primary key..

Let say I have a table wich has the primary key: itemkey,location

table1
------
itemkey
location
...
--------


select * from table1 LIMIT x

gives me the first x row of the result.
After that, I save the last value, and next time, I adjust
the query as

select * from table1 where itemkey>:lastvalue LIMIT x

that should be enough for an 'Item' table, but I have another
column in the primary key.

let say, I have the following in Table1:

itemkey        location
------------------------
00001        00001
00001        00002
...
00005        00001
00005        00002
00005        00003 <--- lets say this is the last value

next time i want to run a query, which starts from

00005        00004
00006        00005

and so on..

How can I specify that in sql?
I dont want to use cursor:), I would like to do it in plain sql.
(It it is possible).

Thank you in advance

Andras Kutrovics

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
</i></font></pre></blockquote>

В списке pgsql-sql по дате отправления:

Предыдущее
От: Andras Kutrovics
Дата:
Сообщение: Simple SQL Question
Следующее
От: Tomasz Myrta
Дата:
Сообщение: Re: Simple SQL Question