Routine to perform the error handling
Posted: Wed Dec 17, 2008 2:40 pm
Hi,
I'm using a routine to do field validations. Multiple fields in a record should be validated for null,maxlength,numeric format,date format. If any of the fileds fail the validation, that record need to be sent to error table and there is no validation required for any other fields for that record.
I implemented this using a routine in conjunction with stage variables. I call the routine with the filed name,field value,maxlength,null flag('Y' or 'N' as the value),numeric flag('Y' or 'N' as the value),date flag ('Y' or 'N' as the value). If a field fails the validation, the routine returns the error column,error code and error name as a concatenated string.I captured the return value and based on it i decide whether to call the routine for the next field or push the record to error table. This works fine.
But the issue is that if I've 10 fields for length check, then I need to have 10 stage variables which is not desirable. I even thought of passing the arguments as a string. Say if 10 fileds need to be checked I will concatenate all these field names with a delimiter. Similarly all other arguments as well and in the routine I'll retrieve each field and do the check.
Can you suggest a better solution.
I'm using a routine to do field validations. Multiple fields in a record should be validated for null,maxlength,numeric format,date format. If any of the fileds fail the validation, that record need to be sent to error table and there is no validation required for any other fields for that record.
I implemented this using a routine in conjunction with stage variables. I call the routine with the filed name,field value,maxlength,null flag('Y' or 'N' as the value),numeric flag('Y' or 'N' as the value),date flag ('Y' or 'N' as the value). If a field fails the validation, the routine returns the error column,error code and error name as a concatenated string.I captured the return value and based on it i decide whether to call the routine for the next field or push the record to error table. This works fine.
But the issue is that if I've 10 fields for length check, then I need to have 10 stage variables which is not desirable. I even thought of passing the arguments as a string. Say if 10 fileds need to be checked I will concatenate all these field names with a delimiter. Similarly all other arguments as well and in the routine I'll retrieve each field and do the check.
Can you suggest a better solution.