List:MySQL++« Previous MessageNext Message »
From:Don Thompson Date:October 8 2004 5:22pm
Subject:Re: compiling mysql++ examples (fwd)
View as plain text  
Hi,
I'm fighting the use of SQLQuery.insert().  I have used this in a 
project before with no problem, but now am
missing something.  I have even written a sample test to study the 
subtle template stuff, and it works like a
charm.  I don't understand the error: request for member 'table' in 'v' 
which is of non-aggregate type... can someone
explain?

thanks




/usr/local/mysql++-1.7.15/sqlplusint/sql_query1.hh: In member function `
   SQLQuery& SQLQuery::insert(const T&) [with T = const CLdata*]':
/usr/local/mysql++-1.7.15/sqlplusint/query1.hh:83:   instantiated from `MysqlQuery&
MysqlQuery::insert(const CLdata&) [with T = const CLdata*]'
cudb.cc:21:   instantiated from here
/usr/local/mysql++-1.7.15/sqlplusint/sql_query1.hh:178: error: request for 
   member `value_list' in `v', which is of non-aggregate type `const CLdata* 
   const'
/usr/local/mysql++-1.7.15/sqlplusint/sql_query1.hh:178: error: request for 
   member `field_list' in `v', which is of non-aggregate type `const CLdata* 
   const'
/usr/local/mysql++-1.7.15/sqlplusint/sql_query1.hh:178: error: request for 
   member `table' in `v', which is of non-aggregate type `const CLdata* const'
make[3]: *** [cudb.o] Error 1




<...code fragment...>
#include <mysql++.hh>

using namespace std;

template <class CLdata> Query& Query::insert(const CLdata &v);


//database access class
class Cdata {
public:
  Cdata() : query(&con, true) {
   try {
    con.real_connect("cu_test_data","localhost","dt","xxx",3306,int(0),60,NULL);
    query = con.query();    
   } catch (BadQuery &er) {
       std::cerr << "mysql err: " << er.error << std::endl;
   }
  }
  ~Cdata();
protected:
  Connection con;
  Query query;
  ...
};

//database access
class CLdata : public Cdata {
private:
  string table_name;
  string field_name_list;
  string field_value_list;
public:
  string& value_list();
  string& table() { return table_name; }
  string& field_list() {
    cout << "field_list() is: " << field_name_list << endl; 
    return field_name_list; 
  }
  CLdata() { 
    table_name = "ttable";
     field_name_list = "first,last,email";  
  }
  void newAdd(LRec &l);
  ...
};

...
// new add Rec
void
CLdata::newAdd(LRec &l) {
  const CLdata junk(*this);
  ...
  query.insert(&junk);
}














Thread
compiling mysql++ examples (fwd)Enrique Farfan5 Oct
  • Re: compiling mysql++ examples (fwd)Warren Young5 Oct
  • Re: compiling mysql++ examples (fwd)Don Thompson8 Oct
    • Re: compiling mysql++ examples (fwd)Warren Young8 Oct
  • Re: compiling mysql++ examples (fwd)Don Thompson8 Oct
    • Re: compiling mysql++ examples (fwd)Warren Young8 Oct
      • Re: compiling mysql++ examples (fwd)Don Thompson9 Oct
        • Re: compiling mysql++ examples (fwd)Chris Frey9 Oct