I'm using Interbase as database server for my Client/Server application. I use combination of trigger and generator for creating the primary key for each table. My problem is, how could I receive the generator value of just-inserted record? Please do remember that we have many users using the application concurrently, receiving the generator value is easy, but I don't know which one is for my session. Currently, I create a stored procedure for inserting value into the database, then return me with the value of the generator. But this way, my code will use stored procedure and will not be compatible with other database. Is there any better idea? I have to migrate this application to other database in the near future, it would be a huge problem if I do it this way.
If you can't answer this question, perhap you can tell me how to get the database connection session id (the id that uniquely generated for each user connection to the database). If I can get the session ID, it wouldn't be hard problem to keep generator value in database along with session ID.