Suppose a manufacturer informs you about the categories of products that will no longer be available. You don't want to have in your database products something that you will not sell. Then you use PDI to delete them.
LUX_discontinued.txt
file. String
constant named man_code
with value LUX
. js
as Connection and, as Target table, browse and select products. In the grid add the conditions man_code = man_code
and pro_theme LIKE category
. After the Delete step, add a Write to log step. js
connection, locate the products
table and click Open SQL for [products].SELECT pro_theme, pro_name FROM js.products p ORDER BY pro_theme, pro_name;
You deleted from the products
table all products belonging to the categories found in the LUX_discontinued.txt
file.
Note that to query the list of products, you used the PDI Database explorer. You could have done the same by using MySQL Query Browser.
The Delete step allows you to delete records of a database table based on a given condition. For each row coming to the step, PDI deletes the records that match the condition set in its configuration window.
Let's see how it worked in the tutorial. The following is the dataset coming to the Delete step:
For each of these two rows PDI performs a new delete operation.
For the first row, the records deleted from the products
table are those where man_code
is equal to LUX
and pro_theme
is like FAMOUS LANDMARKS
.
For the second row, the records deleted from the products
table are those where man_code
is equal to LUX
and pro_theme
is like COUNTRYSIDE
.
You can verify the performed operations by comparing the result sets you got in the database explorer before and after running the transformation.
Just for your information, you could have done the same task with the following DELETE
statements:
DELETE FROM products WHERE man_code = 'LUX' and pro_theme LIKE 'FAMOUS LANDMARKS' DELETE FROM products WHERE man_code = 'LUX' and pro_theme LIKE 'COUNTRYSIDE'
In the Step Metrics result, you may notice that the updated column for the Delete step has value 2. This number is the number of delete operations, not the number of deleted records, which was actually a bigger number.
3.139.103.27