📄 selvalexample.htm
字号:
<pre><code><span class="codeComment">// Assign valid defaults for null values</span>
class Example
{
public: <span class="codeComment">// tablename.columnname:</span>
int exampleInt; <span class="codeComment">// DB_EXAMPLE.INT_VALUE</span>
string exampleStr; <span class="codeComment">// DB_EXAMPLE.STRING_VALUE</span>
double exampleDouble; <span class="codeComment">// DB_EXAMPLE.DOUBLE_VALUE</span>
long exampleLong; <span class="codeComment">// DB_EXAMPLE.EXAMPLE_LONG</span>
TIMESTAMP_STRUCT exampleDate; <span class="codeComment">// DB_EXAMPLE.EXAMPLE_DATE</span>
};
<span class="codeComment">// Validation behavior, assign default values for NULL fields</span>
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;
}
<span class="codeComment">// Now check that values are in acceptable range
// Return false/failure if values out of range</span>
if (rowbuf.exampleDouble > 100)
return false;
return true; // data is OK
}
};</code></pre>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -