// Discard previous errors
ResetLastError();
error = "";
// On failure, put the last error into a variable
Eval(orderType = DBLookup("<TAG>MyProject/Targets/myDbTarget</TAG>",
"SELECT ORDER_TYPE FROM PO_HEADER WHERE PO_NUMBER = " + PO_NUM),
error = GetLastError());
// If an error, raise it with the error in the message
If(Length(error) > 0, RaiseError("Failed to lookup Order Type: " + error), orderType);