Hi, I have the following eSQL statements that I need to convert to C# in a console app... I'm not sure if I'm doing it correctly so any help would be greatly appreciated!
Here is the given eSQL:
DECLARE PRODUCT_UNITS CHARACTER;
DECLARE PRODUCT_ID CHARACTER;
DECLARE output CHARACTER;
IF PRODUCT_UNITS IS NOT NULL THEN
IF PRODUCT_UNITS > 999 THEN
SET PRODUCT_UNITS = '999';
END IF;
END IF;
IF ((PRODUCT_ID IS NOT NULL) AND (PRODUCT_ID <> '')) THEN
DECLARE TEMP_PRODUCT_ID INTEGER;
SET TEMP_PRODUCT_ID = CAST(PRODUCT_ID AS INTEGER);
IF ((TEMP_PRODUCT_ID >= 1 ) AND (TEMP_PRODUCT_ID < 10 ) AND (LENGTH(PRODUCT_ID) < 2) ) THEN
SET output = output || ',@X123="0' || PRODUCT_ID || ' " ';
ELSE
SET output = output || ',@X123=" ' || PRODUCT_ID || ' " ';
END IF;
END IF;
SET output;
Here's what I have so far:
public string Employee(string productUnits, string productId)
{
StringBuilder output = new StringBuilder();
if (!string.IsNullOrEmpty(productUnits))
{
if(int.Parse(productUnits) > 999)
{
productUnits = "999";
}
}
if (!string.IsNullOrEmpty(productId))
{
int tempProductId >= int.TryParse(productId);
if(tempProductId >= 1 && tempProductId < 10 && int.TryParse(productId) < 2)
{
output.Append(",@x123=\"0").Append(productId).Append('"');
}
else
{
output.Append(",@x123=\"").Append(productId).Append('"');
}
}
return output.ToString();
}