X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E41E33A3D82 for ; Fri, 5 Nov 2004 16:54:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85873-02 for ; Fri, 5 Nov 2004 16:54:46 +0000 (GMT) Received: from a.relay.invitel.net (a.relay.invitel.net [62.77.203.3]) by svr1.postgresql.org (Postfix) with ESMTP id 9C80F3A202A for ; Fri, 5 Nov 2004 16:54:43 +0000 (GMT) Received: from vadangyal.vnet.hu (mail.vnet.hu [213.163.59.4]) by a.relay.invitel.net (Invitel Core SMTP Transmitter) with ESMTP id BCB6518D243 for ; Fri, 5 Nov 2004 17:54:42 +0100 (CET) Received: from [192.168.0.144] ([82.131.188.70]) by mail.vnet.hu (iPlanet Messaging Server 5.1 Patch 1 (built Jun 6 2002)) with ESMTPA id <0I6P00KIJTN5OA@mail.vnet.hu> for pgsql-sql@postgresql.org; Fri, 05 Nov 2004 17:54:42 +0100 (CET) Date: Fri, 05 Nov 2004 17:54:41 +0100 From: Andras Kutrovics Subject: Simple SQL Question To: pgsql-sql@postgresql.org Message-id: <418BB051.6070808@freemail.hu> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Enigmail-Version: 0.85.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/49 X-Sequence-Number: 19368 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