Value Validation

I’m looking frantically for a way to validate an incoming value (from a csv file) as numeric prior to inserting in Oracle. The only way I have found to do it so far is to perform some math function on it, such as cast as an integer, and let it bomb, which generates an error message in the log. This could result in an unacceptable amount of trash in the log for my particular client. Is there another way, such as an ‘isnumeric’ service? Any help would be greatly appreciated.

Jennifer

You can use regular expressions to test for numbers. eg. [0-9]

See Appendix D in the ISDeveloperGuide.pdf for details.

So you can test if the field is numeric and then add the steps to handle it either way.

Also, see Appendix E on how to use them, especially syntax on page 580.

So, if I understand what you’re saying, the only way is to validate that each character of the string matches a value of 0-9? There isn’t a less processor-intensive method? Or am I misunderstanding?

Jen

Thank you for the time you took to respond to my question. I appreciate your help.

Jennifer

This is a cut/paste from the PSUtilities package, string folder. The package is downloadable from advantage.

IDataCursor pipelineCursor = pipeline.getCursor();
pipelineCursor.first( "input" );
String input = (String)pipelineCursor.getValue();

String isNumeric = "true"; 
try
{
	float fNumber = Double.valueOf(input).floatValue();
}
catch (Exception e)
{
	isNumeric = "false";
}
finally
{
	pipelineCursor.insertAfter("isNumeric", isNumeric);
	pipelineCursor.destroy();
}