ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bob Hanson" <mnbo...@gmail.com>
Subject Re: insert using a stored procedure
Date Wed, 22 Nov 2006 15:33:59 GMT
You are both showing me how to use the insert element which I already know
how to do.

I thought stored procedures have to use the procedure element.

According to SqlMap.xsd, selectKey is not a valid child element of
procedure.

On 11/22/06, Senthilmurugan, ANGLER - EIT <senthilmurugan@angleritech.com>
wrote:
>
>  <!—Oracle SEQUENCE Example using .NET 1.1 System.Data.OracleClient -->
> <insert id="insertProduct-ORACLE" 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="insertProduct-MS-SQL" parameterClass="product">
>   insert into PRODUCT (PRD_DESCRIPTION)
>   values (#description#)
>  <selectKey resultClass="int" type="post" property="id" >
>    select @@IDENTITY as value
>  </selectKey>
> </insert>
> <!-- MySQL Example -->
> <insert id="insertProduct-MYSQL" parameterClass="product">
>   insert into PRODUCT (PRD_DESCRIPTION)
>   values (#description#)
>  <selectKey resultClass="int" type="post" property="id" >
>    select LAST_INSERT_ID() as value
>  </selectKey>
> </insert>
>
>
>  ------------------------------
> *From:* Dorin Manoli [mailto:Dorin.Manoli@dataireland.ie]
> *Sent:* Wednesday, November 22, 2006 2:19 PM
> *To:* user-cs@ibatis.apache.org
> *Subject:* RE: insert using a stored procedure
>
>  It depend what database engine you use. Code below is for MySQL
>
> Use this code in xml map file under <insert> node and after insert query
>
> <selectKey …. . . . >
>
>                         select LAST_INSERT_ID() as value
>
>                   </selectKey>
>
>
>  ------------------------------
>
> *From:* Bob Hanson [mailto:mnbob70@gmail.com]
> *Sent:* Tuesday, November 21, 2006 6:49 PM
> *To:* user-cs@ibatis.apache.org
> *Subject:* insert using a stored procedure
>
>
>
> What is the correct method to retrieve the Identity value of a newly
> inserted row when using a stored procedure that performs an insert?
>
> Thanks,
> Bob
>

Mime
View raw message