1. 程式人生 > >DB2 插入資料並返回自增長主鍵

DB2 插入資料並返回自增長主鍵

建表語句:

create  table  wqx_XXX (
id  integer not null primary key generated always as identity (start with 1 , increment 1),
name  varchar(200) not null
)
<insert id="insert1'"  parameterClass="eleDto">
insert into   
wqx_XXX(name) values(#name#)


<selectKey resultClass="java.lang.String" keyProperty="id">
select IDENTITY_VAL_LOCAL() as id FROM sysibm.sysdummy1
</selectKey>


</insert>