Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <pqxx/connection>
  2. #include <pqxx/transaction>
  3.  
  4. using namespace pqxx;
  5.  
  6. namespace DOGenerator
  7. {
  8.     using std::string;
  9.  
  10.     DbResult DbInfoLoad::get(const std::string& server, short port,
  11.             const std::string& db, const std::string& user,
  12.             const std::string& password, const std::string& tableName)
  13.     {
  14.         DbResult result;
  15.  
  16.         // form a full server address
  17.         std::ostringstream serverAddress("");
  18.        
  19.         serverAddress << "host="<<server<<" user="<<user<<" password="<<password<<"dbname"<<db;
  20.         /*
  21.         if (port)
  22.             serverAddress << "/" << port;*/
  23.  
  24.         // create connection
  25.         pqxx::connection conn(serverAddress.str());
  26.         // create transaction
  27.         pqxx::work trans(conn);
  28.         //SQL request i guess is wrong, but now i need to write a C++ code
  29.         pqxx::result res(trans.exec(" SELECT TRIM(RL.RDB$RELATION_NAME), TRIM(FR.RDB$FIELD_NAME), FS.RDB$FIELD_TYPE"
  30.             " FROM RDB$RELATIONS RL "
  31.             " LEFT OUTER JOIN RDB$RELATION_FIELDS FR ON FR.RDB$RELATION_NAME = RL.RDB$RELATION_NAME "
  32.             " LEFT OUTER JOIN RDB$FIELDS FS ON FS.RDB$FIELD_NAME = FR.RDB$FIELD_SOURCE "
  33.             " WHERE (RL.RDB$VIEW_BLR IS NULL) "
  34.             " ORDER BY RL.RDB$RELATION_NAME, FR.RDB$FIELD_NAME "));
  35. //       TODO: better sql query
  36.  
  37.         string tName;
  38.         string fieldName;
  39.         int fieldType = -1;
  40.        
  41.         for(pqxx::result::const_iterator it = res.begin();it!=res.end();++it)
  42.         {
  43.             //this is a place which i have no idea how to rewrite.
  44.         }
  45.         //there should be a code =)
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement