You don't need a separate query to get the last inserted id. Have a look at
this
http://docs.wso2.org/display/DSS311/Returning+Generated+Keys


On Mon, Feb 10, 2014 at 4:51 PM, Maduranga Siriwardena
<[email protected]>wrote:

> Hi all,
>
> I'm using a data service and I want to get the last inserted id of a auto
> incremented column from the database. After executing the insert query, I
> call a get resource that execute the following query in the data service
> server.
>
> <query id="get_last_inserted_id" useConfig="default">
>       <sql>SELECT LAST_INSERT_ID() AS LAST_INSERTED_ID</sql>
>       <result element="WSO2_QAP_FEATURECollection"
> rowName="WSO2_QAP_FEATURE">
>          <element column="LAST_INSERTED_ID" name="LAST_INSERTED_ID"
> xsdType="xs:integer"/>
>       </result>
>    </query>
>
> Sometimes I get the correct id and sometimes I get "0" as the last
> inserted id. Can someone help me to resolve this problem or any other
> workaround to get the last inserted id.
>
> Regards
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
*Amila Maharachchi*
Senior Technical Lead
WSO2, Inc.; http://wso2.com

Blog: http://maharachchi.blogspot.com
Mobile: +94719371446
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to