zoukankan      html  css  js  c++  java
  • mybatis.net insert 返回主键

    <insert id="insertORACLE" parameterClass="product"> 
      <selectKey resultClass="int" type="pre" property="Id" > 
         SELECT STOCKIDSEQUENCE.NEXTVAL AS VALUE FROM DUAL
      </selectKey> 
      insert into PRODUCT (PRD_ID,PRD_DESCRIPTION) values (#id#,#description#) 
    </insert>

    — Microsoft SQL Server IDENTITY Column Example --> 
    <insert id="insertMSSQL" parameterClass="product"> 
      insert into PRODUCT (PRD_DESCRIPTION)
      values (#description#) 
     <selectKey resultClass="int" type="post" property="id" > 
       select @@IDENTITY as value
     </selectKey>
    </insert>


    <insert id="insertMYSQL" parameterClass="product"> 
      insert into PRODUCT (PRD_DESCRIPTION)
      values (#description#) 
     <selectKey resultClass="int" type="post" property="id" > 
       select LAST_INSERT_ID() as value
     </selectKey>
    </insert>

  • 相关阅读:
    第36课 经典问题解析三
    第35课 函数对象分析
    67. Add Binary
    66. Plus One
    58. Length of Last Word
    53. Maximum Subarray
    38. Count and Say
    35. Search Insert Position
    28. Implement strStr()
    27. Remove Element
  • 原文地址:https://www.cnblogs.com/tenghoo/p/mybatis_net_insert.html
Copyright © 2011-2022 走看看