Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pqxx/connection>
- #include <pqxx/transaction>
- using namespace pqxx;
- namespace DOGenerator
- {
- using std::string;
- DbResult DbInfoLoad::get(const std::string& server, short port,
- const std::string& db, const std::string& user,
- const std::string& password, const std::string& tableName)
- {
- DbResult result;
- // form a full server address
- std::ostringstream serverAddress("");
- serverAddress << "host="<<server<<" user="<<user<<" password="<<password<<"dbname"<<db;
- /*
- if (port)
- serverAddress << "/" << port;*/
- // create connection
- pqxx::connection conn(serverAddress.str());
- // create transaction
- pqxx::work trans(conn);
- //SQL request i guess is wrong, but now i need to write a C++ code
- pqxx::result res(trans.exec(" SELECT TRIM(RL.RDB$RELATION_NAME), TRIM(FR.RDB$FIELD_NAME), FS.RDB$FIELD_TYPE"
- " FROM RDB$RELATIONS RL "
- " LEFT OUTER JOIN RDB$RELATION_FIELDS FR ON FR.RDB$RELATION_NAME = RL.RDB$RELATION_NAME "
- " LEFT OUTER JOIN RDB$FIELDS FS ON FS.RDB$FIELD_NAME = FR.RDB$FIELD_SOURCE "
- " WHERE (RL.RDB$VIEW_BLR IS NULL) "
- " ORDER BY RL.RDB$RELATION_NAME, FR.RDB$FIELD_NAME "));
- // TODO: better sql query
- string tName;
- string fieldName;
- int fieldType = -1;
- for(pqxx::result::const_iterator it = res.begin();it!=res.end();++it)
- {
- //this is a place which i have no idea how to rewrite.
- }
- //there should be a code =)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement