Retrieving Last Inserted Record ID
Posted: Thu Dec 18, 2008 1:45 am
Hi, all!
Right now I am trying to develop a database front-end to a simple accounts system. Ultimately, there will be 2 versions of the system: a single user, and a multiple-user version. For various reasons, SQLite will be used as the database backend for the single-user version, and PostgreSQL for the multi-user, networked version. In order to implement a consistent user interface for both versions - with minimum of code duplication - I have been trying to program the front end in Revolution, using Rev's Database Library.
I have been able to retrieve, update and delete records so far without any problems, but have come across a pesky little problem while creating a new record. When I create the record, in order to update the interface with the new record ID, I need to know what this ID is. The ID of the record is automatically created by the database - that is, it is an autoincrement integer primary key.
I was wondering if there is a known technique to retrieve the autoincrement id of this last inserted record in a table. I know that different RDBMSs have different internal functions or workarounds that can provide that, but I was wondering whether Revolution had something in its arsenal which was database-independent. Or perhaps one of the Revolution gurus has already worked out a failsafe technique?...
Many thanks in advance for any guidance.
Right now I am trying to develop a database front-end to a simple accounts system. Ultimately, there will be 2 versions of the system: a single user, and a multiple-user version. For various reasons, SQLite will be used as the database backend for the single-user version, and PostgreSQL for the multi-user, networked version. In order to implement a consistent user interface for both versions - with minimum of code duplication - I have been trying to program the front end in Revolution, using Rev's Database Library.
I have been able to retrieve, update and delete records so far without any problems, but have come across a pesky little problem while creating a new record. When I create the record, in order to update the interface with the new record ID, I need to know what this ID is. The ID of the record is automatically created by the database - that is, it is an autoincrement integer primary key.
I was wondering if there is a known technique to retrieve the autoincrement id of this last inserted record in a table. I know that different RDBMSs have different internal functions or workarounds that can provide that, but I was wondering whether Revolution had something in its arsenal which was database-independent. Or perhaps one of the Revolution gurus has already worked out a failsafe technique?...
Many thanks in advance for any guidance.