Received: from leela.one-2-one.net (leela.one-2-one.net [217.115.142.65]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fASEJEm77129 for ; Wed, 28 Nov 2001 09:19:15 -0500 (EST) (envelope-from twanger@bluetwanger.de) Received: from [192.168.0.14] (p3E9EC026.dip.t-dialin.net [62.158.192.38]) by leela.one-2-one.net (8.11.0/8.11.0) with ESMTP id fASEGff07179; Wed, 28 Nov 2001 15:16:42 +0100 Subject: Re: Queue in SQL From: Markus Bertheau To: Gyorgy Molnar Cc: postgres sql list In-Reply-To: <001601c1774d$66bb1b90$3201a8c0@Athlon> References: <001601c1774d$66bb1b90$3201a8c0@Athlon> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-hdrx6R21cCGqW5TgNbwC" X-Mailer: Evolution/0.99.2 (Preview Release) Date: 28 Nov 2001 15:19:13 +0100 Message-Id: <1006957154.4636.47.camel@entwicklung01.cenes.de> Mime-Version: 1.0 X-Archive-Number: 200111/382 X-Sequence-Number: 5764 --=-hdrx6R21cCGqW5TgNbwC Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2001-11-27 at 15:11, Gyorgy Molnar wrote: > How can I retrieve only the first row from a table? > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > 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: >=20 > BEGIN A TRANSACTION > DECLARE CURSOR cursor FOR SELECT > FETCH one row from cursor > Process > CLOSE cursor > DELETE row > COMMIT >=20 > Let say I have 100,000 records in my table, I have to pick up only the fi= rst > row. I do not have any special criteria to execute a query, and I only ne= ed > 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 --=-hdrx6R21cCGqW5TgNbwC Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQA8BPJhKNEjAb345r4RAnc5AJ47MSQkSBGAny4H1oq5fYWEf4/abACcCUmF /yQORKw/Nttr7TdFC5iLs1k= =/Mg8 -----END PGP SIGNATURE----- --=-hdrx6R21cCGqW5TgNbwC--