ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Maves" <nathan.ma...@gmail.com>
Subject Re: Multiple inserts in table with same sequence id
Date Wed, 18 Jul 2007 15:18:05 GMT
Simple....

use the return value from your insert.

Nathan

On 7/18/07, felix thomas <reachfelix@yahoo.co.in> wrote:
> Hi,
>
> I have to insert in 1 Parent table and 4 child tables
> .
>
> I have written sqlMap which inserts in the parent
> table as below.
>
> <insert id="insertCustomField"
> parameterClass="com.sb.model.CustomField" >
>
> <selectKey keyProperty="fieldId" resultClass="int" >
> SELECT record_id.NEXTVAL AS ID FROM DUAL
> </selectKey>
> insert into FIELD (FIELD_ID, NAME, OBJECT_ID,
> SORT_ORDER, FIELD_SIZE, FIELD_TYPE_ID,
> FIELD_TYPE_CODE, DEFAULT_VALUE, IS_STANDARD,
> IS_PRIMARY_KEY, IS_REQUIRED, IS_UNIQUE_VALUE,
> IS_UNIQUE_IGNORE_CASE, IS_EXTERNAL_ID,
> IS_CHANGE_RECORDS, IS_TRACK_CHANGES, LENGTH,
> DECIMAL_PLACES, DISPLAY_FORMAT, STARTING_NUMBER,
> PARENT_OBJECT_ID, LOV_TYPE_ID, IS_LOV_SORT,
> IS_LOV_DEFAULT_FIRST,FORMULA_FIELD_TYPE_ID,
> VISIBLE_LINES, CONTROLLING_FIELD_ID,
> PARENT_SIZE, CHILD_SIZE, LANGUAGE_ID, LABEL,
> DESCRIPTION, CREATED_BY, CREATED_ON, MODIFIED_BY,
> MODIFIED_ON)
> values (#fieldId#,#name:VARCHAR#, 2593,
> #sortOrder:VARCHAR#,
> #fieldSize:NUMERIC#, #fieldTypeId:NUMERIC#,
> #fieldTypeCode:NUMERIC#, #defaultValue:OTHER#,
> 'Y','N','Y','N',
> 'N','N','N','N',
> #length:NUMERIC#, #decimalPlaces:NUMERIC#,
> #displayFormat:VARCHAR#, #startingNumber:NUMERIC#,
> #parentObjectId:NUMERIC#, #lovTypeId:NUMERIC#,
> #isLovSort:CHAR#, #isLovDefaultFirst:CHAR#,
> #formulaFieldTypeId:NUMERIC#, #visibleLines:NUMERIC#,
> #controllingFieldId:NUMERIC#, #parentSize:VARCHAR#,
> #childSize:VARCHAR#,6,
> #label#,
> #description#,1,'17-Jul-2007',1,'17-Jul-2007')
> </insert>
>
> My problem is that i want the fieldId which is
> generated in the sequence to be passed to different
> insert statements for the child tables.
>
> Can it be done in Ibatis. Hope my question is clear.
> Parent table i record inserted , the fieldid generated
> has to be passed to insertion in child table which has
> fielid as foreign key.
>
> 1 Field -> Multiple columns kind of secario.
>
> Regards,
> Felix T
>
>
>
>
>       Get the freedom to save as many mails as you wish. To know how, go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
>

Mime
View raw message