I need to get the primary key for the affected row after performing a MERGE statement, regardless of whether the row got inserted or updated. Is there a standard way to do that? Using the generated key from the statement was my first idea, but it doesn't work quite that way:
http://www.h2database.com/html/grammar.html#merge says that "If the table contains an auto-incremented key or identity column, and the row was updated, the generated key is set to 0; otherwise it is set to the new key." http://www.h2database.com/html/datatypes.html#identity_type says that "Possible values: -9223372036854775808 to 9223372036854775807" So, if 0 is a valid value for an auto-incremented primary key, how am I supposed to know from the generated key value whether a new row with primary key 0 was just inserted (in which case I already have the primary key), or whether a row with some other primary key was updated? -- 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.
