Column Comparator
Table Compare and Stored Procedure Compare can be customized with user logic to compare columns.
Such logic must be coded in a column comparator class which must implement the HPE.Ianus.Scripting.IColumnComparator
interface.
namespace HPE.Ianus.Scripting
{
public interface IColumnComparator
{
void Initialize(Environment env, Task task, DBFieldPair pair);
int Compare(object lo, object ro);
}
}
Therefore it must implement the method Compare
, that takes care of comparing the left and right columns and return the comparison result.
The method Compare
receives the following input parameters:
Parameter | Description |
---|---|
left | Left value |
right | Right value |
Once data is compared, the method should return an integer value indicating the comparison result:
|Return code |Meaning |<0 |The left column is less than right record (left < right) |0 |Columns are equal (left=right) |>0 |The right column is greater than left column (left > right)
The comparator class can be coded in C# when embedded as script, and in any .NET language (including COBOL if available) when provided as DLL.
Note
Ianus provides data to the Compare
method exactly as it reads from the ADO resultset.
Example
public class StringCompareIgnoreCase : IColumnComparator
{
public void Initialize(HPE.Ianus.Environment env, HPE.Ianus.Task task, DBFieldPair pair)
{
}
public int Compare(object lo, object ro)
{
string l = (string)lo;
string r = (string)ro;
return String.Compare(l.Replace('@','.'), r, true);
}
}