How to get the last inserted record from a table ?

:-) Hiee E'body
I work on Oracle 8i and need to get the last
record inserted in a table.
I have tried using rownum and rowid pseudo-columns
but that doesn't work.
Can you please help me out ?
:-) Have a nice time
Vivek Kapoor.
IT, Atul Ltd.,
India.

I'm not sure about 8i features.
I assume here that you don't have 'Date-Time' stamp columns on the table which is the easiest way to determine the last inserted row in the table.
If not try the following :-
select address, piece, SQL_TEXT
from V$SQLTEXT
where upper(sql_text) like '%INSERT INTO TABLE_NAME%'
Substiute the TABLE_NAME with the name of the actual table.
Have fun.
Regards,
Shailender
:-) Hiee E'body
I work on Oracle 8i and need to get the last
record inserted in a table.
I have tried using rownum and rowid pseudo-columns
but that doesn't work.
Can you please help me out ?
:-) Have a nice time
Vivek Kapoor.
IT, Atul Ltd.,
India.

Similar Messages

  • Retrive last inserted  record  from database table

    Hi,
    some body inserting a record into table 'A' through some procedure/java program.i want to retrive the last inserted record from database table.records are not stored in order.Can any body help me.

    In general, unless you are storing a timestamp as part of the row or you have some sort of auditing in place, Oracle has no idea what the "first" or "last" record in a table is. Nor does it track when a row was inserted.
    - If you have the archived logs from the point in time when the row was inserted, you could use LogMiner to find the timestamp
    - If the insert happened recently (i.e. within hours), you may be able to use flashback query to get the value
    - If you're on 10g or later and the table was built with ROWDEPENDENCIES and the insert happened in the last few days and you can deal with a granularity of a few seconds and you don't need 100% accuracy, you could get the ORA_ROWSCN of the row and convert that to a timestamp.
    If this is something you contemplate needing, you need to store the data in the row or set up some sort of auditing.
    Justin

  • How to get large no of records from adf table

    Hi All,
    I'm working on adf.I'm using jdeveloper 11.1.1.5 version.In my adf application i have 1000 records in my adf table.I want to get the 500 selected records from that table at a time.But im not able to get huge number of records.How can i get the records from adf table.Please give me ur valuable suggestions.
    Thanks!

    Hi.
    for large record check the oficial doc.
    http://docs.oracle.com/cd/E24382_01/web.1112/e16182/bcadvvo.htm#CEGDBJEJ
    PAGE_RANGING is the best option for large tables.
    and these maybe will help you
    Re: Performance scrolling large ADF tables
    Re: Expert opinion needed: Best practices to handle huge rowsets on UI

  • How can I get the last / newest record of a table?

    Hi,
    I am developing an ecard app that has a create greeting page, a preview page with edit and send buttons and an edit page.
    I got he insert working, and on the preview page I created a master record page (displays all records), and delete all unecessary designs. Doing it this way also gives me the 'edit' button, so people are able to edit their page.
    How do I get only the last record displayed though? At the moment it loops through all records and displays them in sets of 10. I found the variable that holds the totla count of records ('$totalRows_rs7417_content1'), but how do I (re-)write the script so it ONLY diplays the last record?
    I need to get the ID of this record as I am writing this into the PARAMs of the object and embed tags of my message .swf (this picks up the ID and based on that sucks the greetings text out of the database via another php script.
    Also, from this page, how can I send an email to the sender (ie creator of the message) as well as the recipient? Both email addresses are in the databse so should be part of the erecord returned.
    Thanks,
    Nik

    -----
    OK, So how do I recreate what I got in a non-ADDT list?
    well, when you´re just about to display one certain record, the term "list" is somewhat inappropriate anyway.
    What you´d simply need to do IMHO, is using DW´s native functions to create the basic "SELECT * FROM table_name ORDEr BY ID DESC" query, add "LIMIT 1" manually, and display the desired "dynamic text" placeholders in 1 table cell -- don´t think there were any need for all the fancy stuff
    (sorting, filtering etc) provided by ADDT´s list, as it´s just 1 record.
    It also occurred to me just now that finding the last record that has been added *may-* notbe enough if the site gets used a lot by our executives (I am thinking of a situation where 2 or three peolpe create greetings at the same time and press submit and then getting each others messges rather than their own).
    in this case you might want to additionally store the respective executive´s "kt_login_id" session variable -- because it´s this unique "identifier" which should be used to show the last inserted record of the person who actually inserted it, means adding a "WHERE submitter_id" equals the session variable kt_login_id - clause to the query.
    When creating a non-ADDT list that´s at some point based on detecting a user session, you´ll BTW need to insert at line 1
    I can't seemt o insert it on the page as it is looking for a insert, update or delete bahaviour on the page which of course I don't have
    please search these forums for several posts I made which explain my "use dummy table" approach that´s made for cases when you actually don´t have anything to insert/update/delete, but need "something" for ADDT´s send email behaviours.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • How to get the last inserted Autoincrement value in Java for Pervasive DB

    Hi, I need to get the last inserted auto incremented value after the record is inserted IN JAVA For ex. consider we have 4 columns for the myTable in the PERVASIVE DATABASE V10 autoid - identity column (auto increment column) userID userName pageID insertSqlExpression = insert into myTable (userID , userName, pageID) values( ? ,? ,?); prepareInsert = connection.prepareStatement(insertSqlExpression); prepareInsert .excuteUpdate; After inserting the new record how can I get the autoid value (last inserted value) in the Java. Please help me.
    Thanks in advance. Arthik

    JavaArthikBabu wrote:
    I dont have privileges to write new stored procedures in database.I need to do in the Java side only. In many databases that irrelevant. The same way you would do it in a proc can be done with the correctly conceived statement (singular.)
    For ex – if we insert and then the select record's identity value as a single transaction and would this guarantee that what is returned by the select would not include inserts that another might have made?Please do not take that path unless you are absolutely certain that your database does not support any other way to do it.

  • Query to get the last added record in a table for a particular id

    T
    Hi,
    I have 2 tables A, B
    Table A has id,name
    Table B had parentid(foreignkey referring to ID in above table), record_type,created_timestamp
    I want to get the last added record_type from Table B for all the ids present in Table A.

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. I know this is
    a skeleton, but could you at least try to do good programming? Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. And sample data also helps. 
    I have 2 tables: Alphas, Betas
    CREATE TABLE Alphas
    (alpha_id CHAR(10) NOT NULL PRIMARY KEY,
     alpha_name VARCHAR(25) NOT NULL);
    Why was that DDL so hard you could not write it? But your narrative about the second table does not tell us if it has a key. I will guess that it is also alpha_id, but thanks to your rudeness, that is all we can do. 
    CREATE TABLE Beta 
    (alpha_id CHAR(10) NOT NULL PRIMARY KEY
       REFERENCES Alphas (alpha_id),
     record_type CHAR(2) NOT NULL,
     creation_timestamp DATETIME2(0) DEFAULT CURRENT_TIMESTAMP
          NOT NULL,
    >> I want to get the last added record_type from Table Beta for all the ids present in Table A.<<
    Think about this. Since Beta.alpha_id is a FOREIGN KEY to Alphas, all of its rows will have a match to Alpha. The SQL engine does this for you! 
    SELECT *
    FROM (SELECT alpha_id, record_type, creation_date,
                  MAX(creation_date) OVER () AS creation_date_max
            FROM Betas)
    WHERE creation_date = creation_date_max;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to get the last row of a database table.

    HI ,
    I want to get record exactly from the last row of a database table.
    How is that possible?

    Hi,
    To fetch last record from an internal table, just do find the number of records in it and read using index.
    DESCRIBE TABLE ITAB LINES L_LINES.
    READ TABLE ITAB INDEX L_LINES.
    You can also use LOOP .. ENDLOOP but the above method is better (performance wise).
    using LOOP .. ENDLOOP.
    LOOP AT ITAB.
    **do nothing
    ENDLOOP.
    **process ITAB (Header record of ITAB).
    **after ENLOOP, ITAB will have the last record of the internal table.
    [here ITAB is internal table as well as header record.]
    But what is the requirement?
    If you are looking for the current record of an employee then you can use ENDDA = HIGH_DATE.
    My advice is to review your requirement again and try to fetch only that record which you need.
    Mubeen

  • How to get the last SCN number from catalog database

    Hi All,
    I have a catalog database where my PROD database is registered. Evereyday at 12AM rman takes the hot backup of PROD.
    Now I want to create a auxillary database using the last RMAN backup, for this I want to restore using the SCN from the catalog views.
    Please help me to get the SCN number from the RC_ views.
    Regards,
    Bikram

    asifkabirdba wrote:
    Current SCN:
    Use the dbms_flashback package to get the current SCN. This value will be used during instantiation at the destination site, as well as by RMAN when duplicating the database.
    SET SERVEROUTPUT ON
    DECLARE
    until_scn NUMBER;
    BEGIN
    until_scn:=
    DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER;
    DBMS_OUTPUT.PUT_LINE('Until SCN: ' || until_scn);
    END;
    Regards
    Asif KabirHello,
    i am a bit confused,
    SELECT CURRENT_SCN FROM V$DATABASE;
    6272671324
    and from your package
    SET SERVEROUTPUT ON
    DECLARE
    until_scn NUMBER;
    BEGIN
    until_scn:=
    DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER;
    DBMS_OUTPUT.PUT_LINE('Until SCN: ' || until_scn);
    END;Until SCN: 6272671267
    why are they different, and why first result is lower than yours? can you explain please, thank you
    Ugur MIHCI

  • How to get the last data point from a TDM file in LabVIEW?

    Hello,
    I am using LabVIEW to analyze some rather large TDM files, and I need a way to get only the last data point.  So far, the only way I have been able to accomplish this is by reading the entire file.  Is there a property in the TDM file or a function in LabVIEW that will allow me to get the index of the last item in a channel?  
    Thanks!
    Christina

    Do you want to avoid reading whole file and want to be able to reach or get the index of last value of channel? is there any specific reason? I am not sure you could do it without loading the whole file. But the easiest way would be just to use array functions "array size" would give you the index of last element. 
    -Nilesh
    Kudos are (always) welcome for the good post. :-)

  • How to get the last update time for a table ?

    I want to know the last change of the table data , for example, a record has been changed, how can i get that time?
    Regards,
    Lament

    Hello
    check the tables CDHDR & CDPOS
    But the condition when u r checking the these table.for a particular field the at data element level- futhur charactestictab level we have one check box called change document it as tick
    Thank u,
    santhosh

  • How to remove the duplicate HR record from per_all_people_f table

    Because of some mistake user has created two records for one employee one with start date 4th may 2010 and end date with 1st may 2011 and another with start date with 2nd may 2011 and end date is 31st of dec 2012.
    When I go to enter and maintain employee i found the record which starts with 4th may 2010 and end date with 1st may 2011.
    Please let me know how to remove the end date from this record.
    when I ran the query
    select * from PER_ALL_PEOPLE_F PAPF where upper(first_name)='UDAYA';
    i have first four column for this type.I want to remove the first row from here
    41246     02-MAY-11     31-DEC-12     81     1125
    41246     04-MAY-10     01-MAY-11     81     1125
    Please help.
    Regards,
    Prakash

    Okay, so you wish to just have one person record from the 4th May 2010 through to the 31st December 4712, right?
    In that case, do this:
    1) Query the person in the Enter & Maintain person form
    2) Hit Delete on the toolbar
    3) Select "Delete Next Change" from the date-track mode and save
    4) Re-query
    Now the date-track update from 2nd May is gone.

  • What is the best way to get the end of record from internal table?

    Hi,
    what is the best way to get the latest year and month ?
    the end of record(KD00011001H 1110 2007  11)
    Not KE00012002H, KA00012003H
    any function for MBEWH table ?
    MATNR                 BWKEY      LFGJA LFMON
    ========================================
    KE00012002H        1210             2005  12
    KE00012002H        1210             2006  12
    KA00012003H        1000             2006  12
    KD00011001H        1110             2005  12
    KD00011001H        1110             2006  12
    KD00011001H        1110             2007  05
    KD00011001H        1110             2007  08
    KD00011001H        1110             2007  09
    KD00011001H        1110             2007  10
    KD00011001H        1110             2007  11
    thank you
    dennis
    Edited by: ogawa Dennis on Jan 2, 2008 1:28 AM
    Edited by: ogawa Dennis on Jan 2, 2008 1:33 AM

    Hi dennis,
    you can try this:
    Sort <your internal_table MBEWH> BY lfgja DESCENDING lfmon DESCENDING.
    Thanks
    William Wilstroth

  • How to Get the Unique Key results from OWB Tables after Profile

    Hi,
    We are using OWB 10gR2(Paris) Beta Version.
    In this version the new feature is introduced is Data Profiling.
    We are using this feature to analylize the data in terms of stanadards.
    We have done profiling for our tables and we are able to see the results for each table in OWB Profile Results Canvas. In this window one Unique Key tab is there to see the Unique results.
    Now my question is where these results will be stored in standard tables of OWB. I want to know those exact standard tables to extract thoes Unique results in to my reports.
    After profiling we are generating HTML-DB reports to view all these profile results. But we are not able to find the Uique Key tables where these results are stored.
    So pls can anybody provide help on this to get these tables...
    Thanks in advance...,
    Ramesh P.

    You can use DatabaseMetaData#getPrimaryKeys.

  • Select the last saved records in a table

    I all
    I have this struct in a table
    create table INT_OBJ
    IDOBJ NUMBER(15) not null,
    IDERP NUMBER(15),
    IDE NUMBER(15),
    CPO VARCHAR2(20),
    VLR VARCHAR2(2500),
    VLRC VARCHAR2(2500)
    How to Select the last saved records in a table. I think usea a temp table for put the last row read and begin to read in the next row.
    The table is reading each four hours.

    Theoretically it can be done with ORA_ROWSCN and enabled ROWDEPENDENCIES, but there are so many nuances, so only adding column for ordering is right.
    Regards,
    Sayan Malakshinov

  • Getting the last inserted ID

    I found out about a mySQL function that will get the last inserted autoincrement ID and I want to use it in my page. The prepared statement i am using look like this.
    PreparedStatement insertQuestion1 = ConninsertQuestion1.prepareStatement("INSERT INTO Question.question (Topic_ID, Description, Image, Author, Created_Date, Max_Score, Question_Type)  VALUES ('" + questionData.topicID + "', '" + questionData.questionText + "', '" + questionData.questionImage + "', '" +insertQuestion1__username+ "', '" + currentDate + "', " + questionData.maxScore + ", '" + questionData.questionType + "') ");
              insertQuestion1.executeUpdate();there is a function in mysql which looks like this.
    int mysql_insert_id (resource [link_identifier])
    How can i implement this in my code so i will be able to use the integer value later on to insert more records in another table.
    Help would be much appreciated
    Thanks

    If you are using Java1.4 the approach would be to use :
    public boolean execute(String sql,
    int autoGeneratedKeys)
    throws SQLException
    where the autoGeneratedKeys flag is set to Statement.RETURN_GENERATED_KEYS
    After the insert you can call the method :
    public ResultSet getGeneratedKeys()
    throws SQLException
    Which will return a ResultSet containing the mySQL auto-generated keys.
    Check the documentation
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html
    Note that PreparedStatement inherits these methods from Statement

Maybe you are looking for

  • Infrared Receiver not working on mountain lion 10.8.2.

    I found that just after i updated my OS to its new version the remote control stopped working. Is it a way to get it back again? (i checked on systems preferences but the option for this disappeared) I have a Macbook Pro and it worked before so the i

  • The Report is Empty.

    Hi, Im using Crystal Reports 2008 on VS.NET 2005 and .NET 2.0 I set the dataset to the report programatically. The report viewer is empty. But the report has more than 2 pages. When I click next page on the Crystal Report Toolbar, the report data app

  • Adobe Application Manager won't update on Win 8.1 - cannot install apps

    Since updating this PC to Windows 8.1, the Adobe Application Manager which manages the Creative Cloud apps will not update itself, hence we cannot install or update CC apps (specifically, Acrobat). On clicking the download button on the Acrobat page

  • Problem with cents:"G/L Account Bal. Display (FS10N)  vs. Line Item Display

    Dear colleagues, We have used BSIS table within a batch input program using standard transactions such as F-02 and OASV, in order to leave several "old" G/L accounts completely up to zero, and therefore transferring their complete amount to "new" G/L

  • Commit on each iteration

    I have a problem here with transactions and I'm not to sure how to handle this with Java/JDBC. I have a loop like this: [begin transaction] setAutoCommit(false); [select some rows from table a joined with b] while( there are stil rows ) { [update tab