c++ - Oracle OCCI - get column by name instead of index -
using oracle occi possible instead of supplying index column when requesting data query resultset, pass column name , data?
so instead of doing: (pseudocode)
std::string query = "select name customers;"; std::string myresult = oracle.getstring(1); // name column in query
you'd this:
std::string myresult = oracle.getstring("name"); //column name string
is there way this? have looked around, been unable find anything, besides perhaps going fetch table's metadata.
i read documentation.
it says resultset
has method getcolumnlistmetadata()
, produces vector
of metadata
.
most can use metadata::getstring
find name of column.
and if can use std::map<string, int>
map column names indices.
and name → index mapping in place can implement getstring
takes query result , column name arguments.
possibly has used particular database can better, seems needed take @ documentation.
cheers & hth.,
Comments
Post a Comment