iBatis自動生成的主鍵
很多數據庫支持自動生成主鍵的數據類型
SQL Map 通過<insert>的子元素<selectKey>來支持自動生成的鍵值
Oracle)和後生成兩種類型(如 MS
<
!—Oracle SEQUENCE Example
<insert id=
<selectKey resultClass=
SELECT STOCKIDSEQUENCE
</selectKey>
insert into PRODUCT (PRD_ID
values (#id#
</insert>
<!— Microsoft SQL Server IDENTITY Column Example
<insert id=
insert into PRODUCT (PRD_DESCRIPTION)
values (#description#)
<selectKey resultClass=
SELECT @@IDENTITY AS ID
</selectKey>
</insert>
<!
<insert id=
insert into PRODUCT(PRD_DESCRIPTION)
values (#description#)
<selectKey resultClass=
SELECT LAST_INSERT_ID()
</selectKey>
</insert>
From:http://tw.wingwit.com/Article/program/Oracle/201311/18089.html