Skip to Content
Author's profile photo Dheeraj Kumar

DELETE records from Database with WHERE Clause and then INSERT records

Purpose:

There can be situation when you have to delete records (delete all records from table) and then Insert records, this is possible and easy and there are many Blogs and discussions on this.

Now if a situation comes and you have to delete only particular records with where clause and then Insert records in table, then is it possible? Can you write DELETE query in Message Mapping with where clause? Let’s see the solution below.

Following design needs to be done to make this happen.

Create JDBC Receiver Data Type Structure like below-


/wp-content/uploads/2015/07/pic1_740028.jpg


Explanation for Message Mapping:

Statement1 is for DELETE Query


/wp-content/uploads/2015/07/pic2_740029.jpg


Key1 –> LastName will be used for WHERE condition

The corresponding SQL statement for Statement1 in the example above is as follows:

DELETE FROM dbTableName WHERE (LastName = ‘Kumar’)

Using above design, particulars rows in table dbTableName will be deleted where LastName is Kumar.

Note:

We cannot write DELETE query with where condition in action that is the reason Key1 is used.

Statement2 is for INSERT Query

References:

http://help.sap.com/saphelp_srm40/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.html

Regards

Dheeraj Kumar

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi,

      This feature available from long back right .We often use this .Any thing new ???

      I just want to understand am I missing some thing.

      Regards

      Venkat

      Author's profile photo Dheeraj Kumar
      Dheeraj Kumar
      Blog Post Author

      Hello Venkat

      Yes you are correct this feature is available from long back. This blog is for those who will try to use this feature first time.

      Some of my friends asked about this kind of feature so I thought to write a blog on this.

      Regards

      Dheeraj Kumar

      Author's profile photo Former Member
      Former Member

      Hi Dheeraj,

      Thank you for this. I just started with SAP PI/PO and find this very useful.

      Regards,

      Raye