From: Markus Bertheau <twanger@bluetwanger.de>
To: Gyorgy Molnar <gyorgy.molnar@home.com>
Cc: postgres sql list <pgsql-sql@postgresql.org>
Subject: Re: Queue in SQL
Date: 28 Nov 2001 15:19:13 +0100
Message-ID: <1006957154.4636.47.camel@entwicklung01.cenes.de> (raw)
In-Reply-To: <001601c1774d$66bb1b90$3201a8c0@Athlon>
References: <001601c1774d$66bb1b90$3201a8c0@Athlon>
On Tue, 2001-11-27 at 15:11, Gyorgy Molnar wrote:
> How can I retrieve only the first row from a table?
> ==================
>
> Explanation
> I intend to use libpq and C. as far as I know to retrieve the result from a
> query I need to do the following:
>
> BEGIN A TRANSACTION
> DECLARE CURSOR cursor FOR SELECT
> FETCH one row from cursor
> Process
> CLOSE cursor
> DELETE row
> COMMIT
>
> Let say I have 100,000 records in my table, I have to pick up only the first
> row. I do not have any special criteria to execute a query, and I only need
> the oldest added row (let say the first row if the table is indexed).
> How can I narrow the search criteria, not to receive all of the 100,000
> record in the result?
If I understood you right, you can simply do
select <...> limit 1
Markus Bertheau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: twanger@bluetwanger.de, gyorgy.molnar@home.com
Subject: Re: Queue in SQL
In-Reply-To: <1006957154.4636.47.camel@entwicklung01.cenes.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox