From: | "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu> |
---|---|
To: | hoelc(at)pd(dot)jaring(dot)my |
Cc: | pgsql-general(at)hub(dot)org |
Subject: | Re: [INTERFACES] the last row in a table |
Date: | 1999-03-09 15:20:14 |
Message-ID: | 36E53C2E.C2E59616@alumni.caltech.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-interfaces |
> 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.
Good luck.
- Tom
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Davis | 1999-03-09 16:13:34 | Size of a table in bytes? |
Previous Message | Sze Yuen Wong | 1999-03-09 15:10:27 | Re: [GENERAL] Calcuate percentage. |
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas G. Lockhart | 1999-03-09 17:29:42 | Re: [INTERFACES] Bug in sortin routine? |
Previous Message | Tom Lane | 1999-03-09 15:08:57 | Re: [INTERFACES] Getting field length in libpq |