示例:向學生表中添加記錄
1.MySQL:
<insert id="addStudent" parameterType="Student" keyProperty="id">
insert into student(id,name,birth,score)
values(#{id},#{name},#{birth},#{score});
<selectKey resultType="int" keyProperty="id">
SELECT
LAST_INSERT_ID() AS VALUE
</selectKey>
</insert>
2.SQLServer:
<insert id="addStudent" parameterType="Student" keyProperty="id">
insert into student(name,birth,score)
values(#{#{name},#{birth},#{score});
<selectKey resultType="int" keyProperty="id">
SELECT STOCKIDSEQUENCE.NEXTVAL AS VALUE FROM DUAL
</selectKey>
</insert>
3.Oracle:
<insert id="addStudent" parameterType="Student" keyProperty="id">
insert into student(name,birth,score)
values(#{#{name},#{birth},#{score});
<selectKey resultType="int" keyProperty="id">
select @@identity as inserted
</selectKey>
</insert>
posted on 2014-03-10 10:55
若愚若怯 閱讀(1340)
評論(0) 編輯 收藏 所屬分類:
新手晉級