I am getting this as the result whereas I should get AAAMehAADAAA2c6AAI as that was the latest I inserted into the table.
ROWIDs are not sorted in the insert order, they are just guaranteed to be unique, not sorted in any manner. The only way to keep track of the insert order is to add an INSERT_DATE field populated with SYSDATE or so at insert time.
HTH & Regards,
ORA-000TK : No bind variable detected... Shared Pool Alert code 5 - Nuclear query ready .