New Topic: How to link inserts? Last insert id or insert aliasing?

View: New views
1 Messages — Rating Filter:   Alert me  

New Topic: How to link inserts? Last insert id or insert aliasing?

by LiquiBase Community Forum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A new topic, 'How to link inserts? Last insert id or insert aliasing?', has been made on a board you are watching.

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

The text of the topic is shown below:

Does liquibase have a way to link related rows when doing inserts? Consider the following migration, is there a way to link the role to the person?

Code:
    <changeSet author="jtodd" id="1">
    <insert tableName="person">
    <column name="first_name" value="Bob"/>
                <column name="last_name" value="Smith"/>
    </insert>
        <insert tableName="role">
    <column name="person_id" value="?"/>
                <column name="role" value="manager"/>
    </insert>
    </changeSet>


In sql I would normally do this by getting the last insert id but I think this is something liquibase could handle. In other systems I've used this is accomplished by giving insertions unique id's within the context of the change set. It might look something like this:

Code:
    <changeSet author="jtodd" id="1">
    <insert tableName="person" id="bob_smith">
    <column name="first_name" value="Bob"/>
                <column name="last_name" value="Smith"/>
    </insert>
        <insert tableName="role">
    <column name="person_id" value="bob_smith.id"/>
                <column name="role" value="manager"/>
    </insert>
    </changeSet>


Effectively after each insert, if an id attribute is given to the insert, then it get's put in to a map with the last insert id. Then any reference to this row that follows can use the id that has been assigned. Does anything like this exist?

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.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Liquibase-user mailing list
Liquibase-user@...
https://lists.sourceforge.net/lists/listinfo/liquibase-user