Results 1 to 2 of 2
  1. #1
    Join Date
    May 2010
    Posts
    1

    Unanswered: How to get the last row?

    Hi, sorry for my english, I speak spanish.
    Im newbie to informix.
    How can i obtain the last row of a table, using the insertion order? (the table is not orderable by any column)


    I want something like
    SELECT SKIP (rows - 1) * FROM table;

    I try

    SELECT SKIP (SELECT COUNT(*) -1 FROM TABLE) * FROM TABLE;

    but it doesnt work.
    Some idea? Thanks

  2. #2
    Join Date
    Jul 2009
    Posts
    37
    >
    How can i obtain the last row of a table, using the insertion order? (the table is not orderable by any column)


    The simple answer is that you can't. I recommend you reconstruct your table, preferably with a serial column.

    In theory, well, ROWID would work for you (see IBM Informix Dynamic Server v10 Information Center) but in order for it to work reliably, this places rather a lot of assumptions on how you deal with data in this table (never delete, never update statistics high, never update indexed columns). My advice is to rethink the design of this table and add a serial column, that way you can always get the last row that you just inserted using sqlca.sqlerrd1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •