variant_row_example.htm
来自「The goal of this library is to make ODBC」· HTM 代码 · 共 48 行
HTM
48 行
<pre><code><span class="codeComment">// Manipulating fields in a variant_row</span>
void variant_row_example(void) {
TIMESTAMP_STRUCT test_date = {1999, 9, 29, 0, 0, 0, 0};
vector<TypeTranslation> types;
vector<string> names;
int i;
string s;
TypeTranslation vt0=TypeTranslation(typeid(int).name(), C_INT, SQL_INTEGER, SQL_C_SLONG,
TypeTranslation::TYPE_PRIMITIVE, sizeof(int)),
vt1=TypeTranslation(typeid(string).name(), C_STRING, SQL_VARCHAR, SQL_C_CHAR,
TypeTranslation::TYPE_COMPLEX, sizeof(string));
types.push_back(vt0);
names.push_back("int");
types.push_back(vt1);
names.push_back("string");
variant_row r(types, names);
r["int"] = (int)r["int"] + 5;
i = (int)r["int"];
s = (string) r["int"];
r["int"] = test_date;
s = (string) r["int"];
<span class="codeComment">// Print out the column names</span>
vector<string> colNames = r.GetNames();
for (vector<string>::iterator name_it = colNames.begin(); name_it != colNames.end(); name_it++)
{
cout << (*name_it) << " ";
}
cout << endl;
<span class="codeComment">// Print out all column values</span>
for (i = 0; i < r.size(); i++)
cout << r[i] << " ";
cout << endl;
};
</code></pre>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?