on 10-08-2013 1:51 PM
Hello Experts,
I have a scenario PROXY - PI - JDBC. We have to insert data into two tables based on condition type. Say if condition type = 1, insert the data into first table or else if condition type = 2 insert data into second table.
Please let me know your valuable inputs on this. It is a bit urgent requirement.
Thanks a lot in advance, experts.
Thanks
Ravi
Hi Ravi
Create two statement in your JDBC message structure.
StatementName1
StatementName2
Use createIf function for populating both the statement.
if condion 1 = true --> createIf------>
StatementName1
if condion 2 = true --> createIf------>
StatementName2
Use the follwing structure for your insert query
<StatementName>
<dbTableName action=”INSERT”>
<table>realDbTableName</table>
<access>
<col1>val1</col1>
<col2>val2</col2>
</access>
<access>
<col1>val11</col1>
</access>
</dbTableName>
</StatementName2>
Let me know if you still have any doubts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Indrajit,
Thanks a lot for your quick response. Checked by creating two statements and tested in PI mapping and its working fine.
Will you please elaborate more on the below statement you have provided i.e: How the below query to be used:
Use the following structure for your insert query
<StatementName>
<dbTableName action=”INSERT”>
<table>realDbTableName</table>
<access>
<col1>val1</col1>
<col2>val2</col2>
</access>
<access>
<col1>val11</col1>
</access>
</dbTableName>
</StatementName2>
Thanks
Ravi
Hi Indrajit,
We have a change on the scenario. From source we have a chance to get both conditions at a time as two structures. So for condition 1 we need to insert the data in first table and for the condition 2 we need to insert the data in the second table.
At the same time we have to insert corresponding data into specific tables.
Kindly give your valuable inputs on this.
Thank
Prashanth
Hi Ravi
Please create one strcuture mentioned below for your JDBC structure
Map field action with 'SQL_DML'
Map the field access like below
mention your condition in the if. For test I have used Content = 'X'
in the two constant , write your insert query which will be like below
INSERT INTO tableA VALUES('$fieldvalue1$','$fieldvalue2$')
INSERT INTO tableB VALUES('$fieldvalue1$','$fieldvalue2$')
Finaly map fieldvalue1 and fieldvalue2 with the desired fileds in the source structure.
Hope now you will be able to complete your task. Let me know if you have any doubts.
Very simple. You don't need to create two statements structure. Please check below
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
see the example without placeholder and with placeholder.
You can use that format and in the mapping based on the condition you create string in constant function and map the constant function to the access tag. That's it.
<StatementName>
<anyName action=“SQL_DML”>
<access>Write insert statement here</access>
<key>
<placeholder1>value1</placeholder1>
<placeholder2>value2<placeholder2>
</key>
</anyName >
</StatementName>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi,
If the DB is the same for the two tables you can use the same JDBC receiver communication channel. You only need to map in the message mapping the right DB table discerning with the if standard function to map one table or another in the <table> tag.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.