List:MySQL++« Previous MessageNext Message »
From:Rick Gutleber Date:April 24 2008 6:13pm
Subject:Noob SSQLS problem
View as plain text  

I inherited a project that uses mysql++ as part of a larger C++ class 
library that was meant to incorporate other databases.  Since we no 
longer require such support, I'd like to trim out the tons of overhead 
that "generic" database support required and basically migrate back to 
using mysql++ straight. 

I think SSQLS would fit the bill nicely, but I'm trying a trivial 
example and am getting a confusing error:

Here is my table DDL:

CREATE TABLE `data5m` (
  `interfaceID` int(11) NOT NULL,
  `sampleDate` datetime NOT NULL,

  `min` bigint(20) NOT NULL,
  `max` bigint(20) NOT NULL,
  `average` bigint(20) NOT NULL,
  KEY `sampleDate` (`sampleDate`),
  KEY `interfaceID` (`interfaceID`)

Here is my SSQLS declaration:`````

sql_create_6( data5m, 1, 0,
    int, interfaceID,
    mysqlpp::DateTime, sampleDate,
    std::string, field,
    mysqlpp::sql_bigint, min,
    mysqlpp::sql_bigint, max,
    mysqlpp::sql_bigint, average

and the relevant code in my little experiment is this:

        mysqlpp::Query query = con.query( );
        query << "SELECT MIN( sampleDate ) FROM data5m";

        vector< data5m > result;
        query.storein( result );

        if ( result.size( ) == 0 ) {
            cout << "Nothing found!" << endl;
        } else {
            mysqlpp::DateTime dt = result[ 0 ].sampleDate;

            cout << dt.year << "-" << dt.month << "-" << << " " 
<< dt.hour << ":" << dt.minute <<
                    ":" <<  dt.second << endl;

The error message, which happens on the storein( ) call, is confusing, 
and there must be some simple but non-obvious reason I am getting it:

Conversion error: Bad type conversion: "2008-04-20 22:35:00" 
incompatible with "i" type
        retrieved data size: 4, actual size: 18

Can anyone explain what might be going on here?  I also tried it with 
mysqlpp::sql_datetime, but got the same results.



Noob SSQLS problemRick Gutleber24 Apr
  • Re: Noob SSQLS problemRick Gutleber24 Apr
    • Re: Noob SSQLS problemWarren Young25 Apr
      • Re: Noob SSQLS problemRick Gutleber25 Apr