📄 simpledynamicwrite.htm
字号:
<pre><code><span class="codeComment">// Using a DynamicDBView to insert records into the database.
// Insert two rows into a table with unknown fields</span>
void SimpleDynamicWrite() {
TIMESTAMP_STRUCT paramDate = {2012, 12, 23, 0, 0, 0, 0};
<span class="codeComment">// Mayan DOOMSDAY! End of the Mayan 5126 year long calendar cycle starting from May 1, 3094 B.C.
// Date is 13.13.13.0.0.0.0 4 Ahaw, 3 K'ank'in</span>
DynamicDBView<> view("DB_EXAMPLE", "*");
DynamicDBView<>::insert_iterator write_it = view;
<span class="codeComment">// NOTE: We need to construct r from the view itself since we
// don't know what fields the table will contain.
// We therefore make a call to the DataObj() function to have the
// table return us a template row with the correct number of fields
// and field types.</span>
variant_row r(view.DataObj());
<span class="codeComment">// Prepare the number of the beast!
// Set all fields to the value 6,
// except for the last column which is a date and cannot
// currently accept numeric values</span>
for (size_t i = 0; i < r.size()-1; i++)
{
r[i] = 6;
}
r[i] = paramDate; <span class="codeComment">// set the Doomsdate</span>
<span class="codeComment">// insert the number</span>
*write_it = r;
write_it++;
<span class="codeComment">// Prepare the number of angels who stand before
// the throne of God!
// Set all fields to the value 7,
// except for the last column which is a date and cannot
// currently accept numeric values</span>
for (i = 0; i < r.size()-1; i++)
{
r[i] = 7;
}
r[i] = paramDate;
<span class="codeComment">// insert the number</span>
*write_it = r;
write_it++;
}
</code></pre>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -