If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > How to get the last row?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-06-10, 17:53
martinc martinc is offline
Registered User
 
Join Date: May 2010
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 05-07-10, 17:29
bigcalm bigcalm is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On