// Assign valid defaults for null values

class Example
{
  public:					// tablename.columnname:
	int exampleInt;	    			// DB_EXAMPLE.INT_VALUE
	string exampleStr;			// DB_EXAMPLE.STRING_VALUE
	double exampleDouble;			// DB_EXAMPLE.DOUBLE_VALUE
	long exampleLong;			// DB_EXAMPLE.EXAMPLE_LONG
	TIMESTAMP_STRUCT exampleDate;		// DB_EXAMPLE.EXAMPLE_DATE
};

// Validation behavior, assign default values for NULL fields
template<> class dtl::DefaultSelValidate<Example> 
{
public:
bool operator()(BoundIOs &boundIOs, Example &rowbuf) {
	if (boundIOs["INT_VALUE"].IsNull()) {
		rowbuf.exampleInt = 0;	
	}
	if (boundIOs["STRING_VALUE"].IsNull()) {
		rowbuf.exampleStr = "";	
	}
	if (boundIOs["DOUBLE_VALUE"].IsNull()) {
		rowbuf.exampleDouble = 0;	
	}
	if (boundIOs["EXAMPLE_LONG"].IsNull()) {
		rowbuf.exampleLong = 0;	
	}
	if (boundIOs["EXAMPLE_DATE"].IsNull()) {
		const TIMESTAMP_STRUCT defaultDate = {2000, 1, 1, 0, 0, 0, 0};
		rowbuf.exampleDate = defaultDate;	
	}

	// Now check that values are in acceptable range
	// Return false/failure if values out of range
	if (rowbuf.exampleDouble > 100)
		return false;

	return true;	// data is OK
}

};