Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: query on last inserted record.....please help

Re: query on last inserted record.....please help

From: DA Morgan <damorgan_at_x.washington.edu>
Date: Wed, 22 Dec 2004 16:57:28 -0800
Message-ID: <41ca16f3$1_3@127.0.0.1>


Michel Cadot wrote:

> <madhusudan.hv_at_gmail.com> a écrit dans le message de
> news:1103707234.740544.285300_at_z14g2000cwz.googlegroups.com...
> | my table structure is like this
> | tablename: address
> |
> | 1.patientuid - foreign key referring to patient table
> | 2.addressuid
> | 3. street
> | 4. city
> | 5. addresstype - foreign key referring to address table
> |
> | this database is currently running on many client sites.
> | the application allows us to insert multiple addresses and it used
> | to show all of them on the gui.
> | now according to the new requirement we have show only the last
> | inserted
> | address by making changes only in query code and not touching the
> | database.
> | how to fetch the last inserted record for each patient?
> | please help me........
> |
>
> If you don't already have a timestamp somewhere, you can't.
> But if addressuid is an ordered id then you can use it as timestamp.
>
> Regards
> Michel Cadot

Unless 10g in which case the following might work:

SELECT ...
FROM ...
WHERE ora_rowscn = (

    SELECT MAX(ora_rowscn)
    FROM ...); and will definitely work if the table was built with the ROWDEPENDENCIES clause.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Received on Wed Dec 22 2004 - 18:57:28 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US