本文整理汇总了C++中CppSQLite3Table::getIntField方法的典型用法代码示例。如果您正苦于以下问题:C++ CppSQLite3Table::getIntField方法的具体用法?C++ CppSQLite3Table::getIntField怎么用?C++ CppSQLite3Table::getIntField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CppSQLite3Table
的用法示例。
在下文中一共展示了CppSQLite3Table::getIntField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
try
{
int row;
CppSQLite3DB db;
cout << "SQLite Header Version: " << CppSQLite3DB::SQLiteHeaderVersion() << endl;
cout << "SQLite Library Version: " << CppSQLite3DB::SQLiteLibraryVersion() << endl;
cout << "SQLite Library Version Number: " << CppSQLite3DB::SQLiteLibraryVersionNumber() << endl;
remove(gszFile);
db.open(gszFile);
////////////////////////////////////////////////////////////////////////////////
// Demonstrate getStringField(), getIntField(), getFloatField()
////////////////////////////////////////////////////////////////////////////////
db.execDML("create table parts(no int, name char(20), qty int, cost number);");
db.execDML("insert into parts values(1, 'part1', 100, 1.11);");
db.execDML("insert into parts values(2, null, 200, 2.22);");
db.execDML("insert into parts values(3, 'part3', null, 3.33);");
db.execDML("insert into parts values(4, 'part4', 400, null);");
cout << endl << "CppSQLite3Query getStringField(), getIntField(), getFloatField() tests" << endl;
CppSQLite3Query q = db.execQuery("select * from parts;");
while (!q.eof())
{
cout << q.getIntField(0) << "|";
cout << q.getStringField(1) << "|";
cout << q.getInt64Field(2) << "|";
cout << q.getFloatField(3) << "|" << endl;
q.nextRow();
}
cout << endl << "specify NULL values tests" << endl;
q = db.execQuery("select * from parts;");
while (!q.eof())
{
cout << q.getIntField(0) << "|";
cout << q.getStringField(1, "NULL") << "|";
cout << q.getIntField(2, -1) << "|";
cout << q.getFloatField(3, -3.33) << "|" << endl;
q.nextRow();
}
cout << endl << "Specify fields by name" << endl;
q = db.execQuery("select * from parts;");
while (!q.eof())
{
cout << q.getIntField("no") << "|";
cout << q.getStringField("name") << "|";
cout << q.getInt64Field("qty") << "|";
cout << q.getFloatField("cost") << "|" << endl;
q.nextRow();
}
cout << endl << "specify NULL values tests" << endl;
q = db.execQuery("select * from parts;");
while (!q.eof())
{
cout << q.getIntField("no") << "|";
cout << q.getStringField("name", "NULL") << "|";
cout << q.getIntField("qty", -1) << "|";
cout << q.getFloatField("cost", -3.33) << "|" << endl;
q.nextRow();
}
q.finalize();
////////////////////////////////////////////////////////////////////////////////
// Demonstrate getStringField(), getIntField(), getFloatField()
// But this time on CppSQLite3Table
////////////////////////////////////////////////////////////////////////////////
cout << endl << "CppSQLite3Table getStringField(), getIntField(), getFloatField() tests" << endl;
CppSQLite3Table t = db.getTable("select * from parts;");
for (row = 0; row < t.numRows(); row++)
{
t.setRow(row);
cout << t.getIntField(0) << "|";
cout << t.getStringField(1) << "|";
cout << t.getIntField(2) << "|";
cout << t.getFloatField(3) << "|" << endl;
}
cout << endl << "specify NULL values tests" << endl;
for (row = 0; row < t.numRows(); row++)
{
t.setRow(row);
cout << t.getIntField(0, -1) << "|";
cout << t.getStringField(1, "NULL") << "|";
cout << t.getIntField(2, -1) << "|";
cout << t.getFloatField(3, -3.33) << "|" << endl;
}
cout << endl << "Specify fields by name" << endl;
for (row = 0; row < t.numRows(); row++)
{
t.setRow(row);
cout << t.getIntField("no") << "|";
cout << t.getStringField("name") << "|";
cout << t.getIntField("qty") << "|";
//.........这里部分代码省略.........