Discussion:
[Liquibase-user] New Topic: Getting the autoincrement value to use in latest insert statement
Liquibase Community Forum
2011-01-11 13:13:19 UTC
Permalink
A new topic, 'Getting the autoincrement value to use in latest insert statement', has been made on a board you are watching.

You can see it at
http://liquibase.org/forum/index.php?topic=921.new#new

The text of the topic is shown below:

When I have a change set:
Code:
<changeSet id="1" author="trond">
<insert tableName="mytable">
<column name="id" autoIncrement="true" />
<column name="type">5</column>
</insert>
..


The ID column is a autoIncrement and the value which is used for this ID should be used in another insert statement. Is there any "Liquibase way" of getting this value? If so - how?

An alternative approach is to use a custom SQL which fetches the value. Since I use MySQL, I can use the LAST_INSERT_ID() function to fetch this value, but how do I put this value into a variable that Liquibase can utilize?

Unsubscribe to new topics from this board by clicking here: http://liquibase.org/forum/index.php?action=notifyboard;board=1.0

Regards,
The Liquibase Community Forum Team.

Loading...