Re: Simple SQL Question

From: Bricklen <bricklen(at)zyahoo(dot)zcomz>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Simple SQL Question
Date: 2004-11-05 17:13:46
Message-ID: exOid.82125$df2.43102@edtnps89
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andras Kutrovics wrote:
> 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

maybe the OFFSET keyword will help here?

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Franco Bruno Borghesi 2004-11-05 18:09:20 Re: Simple SQL Question
Previous Message Chethana Kuloor 2004-11-05 17:05:24 Scheduling Jobs In PostgreSQL