You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Paul Glezen <pg...@us.ibm.com> on 2005/08/20 03:58:40 UTC

Re: selectKey with Oracle (resolved)





Being Oracle-challanged myself, I approached my friendly DBA with the
problem.  I was told that a different function call was used for the same
purposed and called after the insert.  Perhaps each Oracle shop has their
own such function.  So I modified the name and flipped the order of my
insert statement and key like this.

<insert id="addProduct" parameterClass="xyz.ProductEntityBean">
   insert into mrt_product (COMPANY_ID, DIVISION_ID, UPC_NO)
            values (#companyId#, #divisionId#, #upcNo#)
  <selectKey keyProperty="uniqueProductId" resultClass="long">
     select pkg_sequence.f_read_sequence_value() as id from dual
  </selectKey>
</insert>

After my call to addProduct, my object has the uniqueProductId field
populated.

Paul