Re: Queue in SQL

From: Markus Bertheau <twanger(at)bluetwanger(dot)de>
To: Gyorgy Molnar <gyorgy(dot)molnar(at)home(dot)com>
Cc: postgres sql list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Queue in SQL
Date: 2001-11-28 14:19:13
Message-ID: 1006957154.4636.47.camel@entwicklung01.cenes.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Johnny Jørgensen 2001-11-28 14:40:25 PL/pgSQL loops?
Previous Message Glenn MacGregor 2001-11-28 14:07:07 View question