Hello Daniel,
Thanks very much for your compliments. We always enjoy receiving feedback like yours.
Your requirement is certainly doable; it just needs a little manual preparation. You need a
.NET Script Heater
, a
Filter Heater
and the following short C# script.
public object DoWork()
{
bool bRet = false;
if (InValues.Length != 2)
throw new Exception("2 input parameter expected");
// do not execute in test mode
if (AdapterWrite.OnlyTest)
return bRet;
// 1. input parameter = filter / delete criteria
string filter = (string)InValues[0].GetString();
// for example; if filter = 5 then delete this record
if ( filter == "5" )
{
// 2. input parameter = PrimaryKey
string id = (string)InValues[1].GetString();
// build DELETE SQL
// !!! CAUTION: you have do use your table and field names !!!
string sql = "delete from YOUR_TABELLE where id = " + id.Replace(".", "").Replace(",", "");
// if your field type is char or varchar use this syntax
//string sql = "delete from YOUR_TABELLE where id = '" + id + "'";
// Execute the SQL statement on the WRITE
AdapterWrite.Execute(sql);
// filter this record
bRet = true;
}
return bRet;
}
Drag a .NET Script Heater and a Filter Heater onto the
Designer
. Connect the
Excel
field deciding your deletion criteria to the first input of the .NET Script Heater. As its second input connect the Excel field that contains the Primary Key information for the Update. Next connect the output of the.NET Script Heater to the Filter Heater. Now you have to copy and paste the above script code into the .NET Script Heater properties and manually adapt it for your MySQL table name, your
MySQL
Primary Key field name and your filter/deletion criteria. Take note of the comments in the script.
CAUTION: Please take care when making use of this method. If an incorrect SQL WHERE condition is entered here you could inadvertently delete the wrong database rows or even the entire table contents!