cancel
Showing results for 
Search instead for 
Did you mean: 

Insert Multiple rows - JDBC Receiver Adapter

baskar_ramasamy
Participant
0 Kudos

Hi Experts,

I have a scenario , where the record needs to be inserted in Multiple rows, I searched in scn and following some blogs, but still no luck.

  Below is the input structure:

 

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_TGTDB_0 xmlns:ns0="http://multiplerow">

   <tbldummy_PI_test>

      <row>

         <MemberID>M1</MemberID>

         <MemberName>Baskar</MemberName>

         <Premium>

            <PremiumID>Pi</PremiumID>

            <PremiumName>Siva</PremiumName>

         </Premium>

      </row>

   </tbldummy_PI_test>

</ns0:MT_TGTDB_0>

I want the data to be inserted multiple rows in table as below

 

M1 | Baskar

P1 | Siva

 

But right now , only 1 row inserted.

 

M1 | Baskar

Note: i have duplicated "access" and mapped to PremiumId & PremiumName , but it seems PI is not accepting access1.

Attachment has the configurations done.

MessageMapping Definition: MM_Definition.PNG

MessageMapping Test:MM_Test.PNG

Communication channel monitoring: CC.PNG

Thanks in advance,

Baskar

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

Baskar,

Why you have given name for second record as access1? that is wrong change it to access.

If you wanna update multiple records in same table then you have to generate access tag twice using mapping.map root node of row to access .

Thank you,

Raj

Former Member
0 Kudos

Hi Raja, loordh.

We cannot do that because when we duplicate access or statement nodes in data type it wii give an error saying "duplicate nodes" we should look for other options.

Thanks.

baskar_ramasamy
Participant
0 Kudos

Raj,

I tried copying access node and , i am getting error as duplicated while activating.

i don't understand what do you mean by "Generate access tag twice" , request you to explain

Thanks,

Baskar

allamudi_loordh
Active Participant
0 Kudos

MT_IB

_STATEMENTINSERT1

__EMP_QUALIFICATION

___ACTION(insert)

       Table

____access

          Xyz

          Mno

_STATEMENTINSER2

__EMP_QUALIFICATION

___ACTION(insert)

       Table

____access

          Xyz

          Mno

try the format.

Answers (4)

Answers (4)

baskar_ramasamy
Participant
0 Kudos

Thanks all for all your support to fix this issue.

Baskar

ambrish_mishra
Active Contributor
0 Kudos

Hi Baskar,

You need to do an intermediate mapping to arrive at an intermediate structure like below:

So your interface will have 2 graphical mappings instead of 1. In the first mapping, you will populate your intermediate structure with the outcome as below:

     <row>

         <MemberID>M1</MemberID>

         <MemberName>Baskar</MemberName>

    </row>

     <row>

         <MemberID>Pi</MemberID>

         <MemberName>Siva</MemberName>

         </row>

this will be dependent on the source structure and Occurance of nodes row, Premium.If you can send that, I can help further.

In the second mapping you populate the JDBC structure.

Then you can map the row (with remove context) to the Statements node in the target; access can be mapped to a constant while the fields can be mapped one to one.

Then you will surely be able to populate the target JDBC structure with 2 records as desired.

Hope it helps!

Ambrish

ambrish_mishra
Active Contributor
0 Kudos

Baskar,

Here is how you do the first mapping. It turned out to be very simple.

You map row in source to First Row in the target. Duplicated Row is mapped to Premium.

rest fields are mapped one to one.

I tested it with following test case:

It works...

Now you map the intermediate structure in next mapping to JDBC structure like I suggested.

Map row(removeContext to Statements.

access to be mapped to constant.

rest fields one to one.

check in database

Hope it helps!

Ambrish

Updated with a better screenshot of first mapping Message was edited by: Ambrish Mishra

ambrish_mishra
Active Contributor
0 Kudos

Hi Baskar,

My bad!

I did not look at the source message type clearly. let me figure out a solution and revert back.

Ambrish

PS: I have deleted my posts so that others are not confused but the solution will be on same line.

allamudi_loordh
Active Participant
0 Kudos

Hi Baskar,

you can go ahead two statements parallel execution. so create 2 statements indivually in one message and update  with different row.

second option is give pass sql query directly and execute.

Regards,

Loordh