Received: from arka.opole.mtl.pl (root@arka.opole.mtl.pl [195.117.41.4]) by hub.org (8.9.2/8.9.1) with ESMTP id MAA69509 for ; Tue, 9 Mar 1999 12:41:42 -0500 (EST) (envelope-from ojciec@mtl.pl) Received: from yasmina (yasmina.opole.mtl.pl [195.117.41.11]) by arka.opole.mtl.pl (8.8.7/8.8.5) with SMTP id SAA03246 for ; Tue, 9 Mar 1999 18:32:48 +0100 (CET) Message-Id: <3.0.6.32.19990309183251.007fd2a0@mtl.pl> X-Sender: ojciec@mtl.pl X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Tue, 09 Mar 1999 18:32:51 -0800 To: pgsql-general@hub.org From: Marcin Grondecki Subject: Re: [GENERAL] Re: [INTERFACES] the last row in a table In-Reply-To: <36E53C2E.C2E59616@alumni.caltech.edu> References: <36E163D7.CD95C55A@pd.jaring.my> <87emn1fwsq.fsf@tolikus.hq.aaanet.ru> <36E50F4A.CB527B78@pd.jaring.my> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" At 15:20 99-03-09 +0000, you wrote: >> I am developing a database with PostgreSQL in Linux, and using ecpg to >> write the C program to communicate with the database. >> One of my application need to get the data from the last row in a >> table. Is there any function or command that can tract which is the >> last row of data in a table? > >SQL is a set-oriented language. One should probably not assign any >significance to a storage order of rows. > >It *is* possible to order the results of a query, and then your >first/last qualities do have meaning. I would suggest ordering your >query (perhaps on a "row update time" if by "the last row" you mean "the >more recently entered row") using the "DESC" qualifier in the ORDER BY >clause, then use a cursor to pick up the first row returned. > There is better answer, i think. Simply read smth about cursors - declaring, using, droping. I think this is what u need. In case of troubles with understanding, i'd serve with some examples in Perl. Marcin Grondecki ojciec@mtl.pl +48(604)468725 ***** I'm not a complete idiot, some parts are missing...