示例:向学生表中添加记录
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
若愚若怯 阅读(1336)
评论(0) 编辑 收藏 所属分类:
新手晋级