Skip to Content
avatar image
Former Member

Insertion of more than one record into database table

Hi friends,

I am doing an IDoc to JDBC scenario.can you please tell me how I can insert more than one record using a single connection.

regards

Debansu

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Aug 12, 2008 at 12:13 PM

    U can use multiple statement nodes as mentioned here

    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm

    Regards,

    Prateek

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      sample

      insert into tab1 (col1, col2) values ('val1-1','val1-2')

      insert into tab1 (col1, col2) values ('val2-1','val2-2')

      insert into tab1 (col1, col2) values ('val3-1','val3-2')

      <ns0:InsertStmt xmlns:ns0="http://xyz.com/insert">
        <InsertStatement>
         <TAB1 action="INSERT">
          <table>tab1</table> 
          <access>
           <col1>val1-1</col1> 
           <col2>val1-2</col2> 
          </access>
          <access>
            <col1>val2-1</col1> 
            <col2>val2-2</col2> 
          </access>
          <access>
           <col1>val3-1</col1> 
           <col2>val3-2</col2> 
          </access>
         </TAB1>
        </InsertStatement>
        </ns0:InsertStmt>
      

      Regards Dieter

  • avatar image
    Former Member
    Aug 12, 2008 at 12:20 PM

    sarkar then use the following format :

    <StatementName1>

    <dbTableName action=u201DINSERTu201D>

    <table>realDbTableName</table>

    <access>

    <col1>val1</col1>

    <col2>val2</col2>

    </access>

    <access>

    <col1>val11</col1>

    </access>

    </dbTableName>

    </StatementName1>

    <StatementName2>

    <dbTableName action=u201DINSERTu201D>

    <table>realDbTableName</table>

    <access>

    <col1>val1</col1>

    <col2>val2</col2>

    </access>

    <access>

    <col1>val11</col1>

    </access>

    </dbTableName>

    </StatementName2>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 12, 2008 at 12:30 PM

    Hi,

    Please tell me how to do the mapping.I have made the occurence of 'statementname' as 1..unbounded.Still it is not working.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Test in ur Message Mapping,.

      your InsertStatements created as many times as number of items to be inserted...

  • avatar image
    Former Member
    Aug 12, 2008 at 12:45 PM

    Here is the Typ-Definition of InsertStmt for insert into tab1 (col1, col2)

    
    InsertStmt     comlex type
       InsertStatment   Element occurs 1
          tab1               Element occurs 1
             action          Attribute occurs 1 default "INSERT"
             table           Element occurs 1
             access       Element  occurs 1 .. unbound
                col1         Element occurs 1
                col2         Element occurs 1
       InsertStatement_response Elemment occurs 0..1
           insert_count   Element occurs 1
    

    the InsertStatement_response part will be filled when JDBC returns.

    Edited by: Dieter Glauß on Aug 12, 2008 2:45 PM

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Dieter,

      Thanks for the help.The problem has been solved.Just wanted to point out two things:

      Action is an attribute which can take two values i.e optional or required

      During mapping of Access with corresponding segment of IDoc,we have to do a remove context.

      regards

      Debansu

      Edited by: Debansu Sarkar on Aug 12, 2008 8:19 PM

  • avatar image
    Former Member
    Aug 12, 2008 at 02:52 PM

    Thanks to all,problem has been resolved.

    Add comment
    10|10000 characters needed characters exceeded