int main3(void) { ofstream of; of.open("out.tsv"); try { Environment::Initialize(); Connection con("localhost", "scott", "tiger"); Statement st(con); st.Execute("select * from APEX_040000.WWV_FLOW_STEP_ITEMS"); Resultset rs = st.GetResultset(); auto colCount = rs.GetColumnCount(); cout << colCount << '\n'; for (int i=1; i <=colCount; i++){ cout << rs.GetColumn(i).GetName() << "|" << rs.GetColumn(i).GetFullSQLType() << '\n'; } while (rs++) { for (int i = 1; i <= colCount; i++){ of << rs.Get<ostring>(i); if (i < colCount){ of << "\t"; } } of << "\n"; } std::cout << "=> Total fetched rows : " << rs.GetCount() << std::endl; } catch (std::exception &ex) { std::cout << ex.what() << std::endl; } Environment::Cleanup(); of.close(); return EXIT_SUCCESS; }
void test_fetch(void) { ocout << otext("\n>>>>> SIMPLE TEST FETCH WITH META DATA\n\n"); Statement st(con); st.Execute(otext("select * from test_fetch")); Resultset rs = st.GetResultset(); for (int i = 1, n = rs.GetColumnCount(); i <= n; i++) { ocout << otext("> Field : #") << i << otext(" - Name : ") << rs.GetColumn(i).GetName() << oendl; } ocout << oendl; while (rs++) { PrintProductFromQuery(rs); } ocout << oendl << rs.GetCount() << otext(" row(s) fetched") << oendl; }