Thomas, Sorry for nagging but I am truly blocked on this issue. I need to use in-memory database for my unit tests (in order to ensure that tests do not interact with one another) but I also need TRANSACTION_ID() to implement and test audit tables. For what it's worth, here is what other databases provide:
Postgres' txid_current() returns a BIGINT: http://www.postgresql.org/docs/current/static/functions-info.html HSQLDB's TRANSACTION_ID() returns a BIGINT: http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html Oracle's LOCAL_TRANSACTION_ID() returns a VARCHAR2: http://psoug.org/reference/dbms_transaction.html It seems that HSQLDB's TRANSACTION_ID() works for in-memory databases. All I really need is to be able to differentiate between different transactions in the same session. Gili On Jun 11, 12:46 pm, cowwoc <[email protected]> wrote: > On 11/06/2011 12:25 PM, Thomas Mueller wrote:> Hi, > > >> Okay. How do you generate the same sequence id for different triggers > >> in > >> the same transaction (and different ids for different transactions)? > > The first operation in the transaction could generate a new sequence > > id, and all other operations could then use the last value of the > > generated sequence:http://h2database.com/html/functions.html#currval > > > I guess this is how I would solve the problem. It is relatively > > database independent. > > > Regards, > > Thomas > > Hi Thomas, > > I need help understanding your proposal. Looking > athttp://h2database.com/html/functions.html#currval > > 1. Does "session" refer to a database connection? > 2. I am concerned about the part of the description that reads > "independent of the session". Doesn't this mean that if two connections > run concurrently CURRVAL() may lead to race-conditions? > 3. I'm trying to use transaction IDs in database triggers. I have no way > of knowing which one runs first, as such I don't know when to run > NEXTVAL() and when to run CURRVAL(). Any suggestions? > 4. Assuming we get this working, why did you decide to implement > TRANSACTION_ID() in terms of a UUID string instead of this approach? The > only benefit I can think of is cross-database uniqueness, but for single > databases it seems the performance would be worse...? > > Thanks, > Gili -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
