コード例 #1
0
int main()
{
    DBHelper db;

    try
    {
        db.connect("retstest");

        string query("SELECT ListingID,ListDate");
        query.append("  FROM data:Property:RES");
        query.append(" WHERE ListPrice > 0");

        cout << db.executeQuery(query) << endl;

        int num = db.numResultCols();
        cout << "Search Result has " << num << " columns" << endl;
        num = db.rowCount();
        cout << "Search Result has " << num << " rows" << endl;

        cout << db.describeColumn(1) << endl;

        ResultColumnPtr col1(new CharResultColumn(1024));
        db.bindColumn(1, col1);

        cout << db.describeColumn(2) << endl;

        ResultColumnPtr col2(new TimestampResultColumn());
        db.bindColumn(2, col2);
    
        cout << "pre fetch" << endl;
        while (db.fetch())
        {
            cout << col1 << "    ";
            cout << col2 << endl;
        }

        db.disconnect();
    }
    catch (std::exception& e)
    {
        cout << e.what() << endl;
    }
}
コード例 #2
0
int main(int argc, char *argv[])
{
    try
    {
        DBHelper db;

        if (argc > 1)
        {
            db.connect(argv[1]);
        }
        else
        {
            db.connect("retstest");
        }

        db.tables();

        ResultColumnPtr col3(new CharResultColumn(256));
        db.bindColumn(3, col3);

        ResultColumnPtr col4(new CharResultColumn(256));
        db.bindColumn(4, col4);

        ResultColumnPtr col5(new CharResultColumn(256));
        db.bindColumn(5, col5);

        cout << "pre fetch" << endl;
        while (db.fetch())
        {
            cout << col3 << "    ";
            cout << col4 << "    ";
            cout << col5 << "    " << endl;
        }
    
        db.disconnect();
    }
    catch(std::exception& e)
    {
        cout << e.what() << endl;
    }
}