List:MySQL++« Previous MessageNext Message »
From:Rick Gutleber Date:April 24 2008 6:21pm
Subject:Re: Noob SSQLS problem
View as plain text  
Of course, as always happens, I realize what I have done wrong 
immediately after asking the question.  I guess SSQLS expects the 
results of the query to match the _whole_ list of fields presented in 
the declaration.  I would only use the SSQLS stuff when I am retrieving 
whole records, not a single field like I am doing in the code I posted.

Thanks for your help.  ;-)

Rick


Rick Gutleber wrote:
> Hi:
>
> 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,
>  `field` 
>
> enum('ifOutErrors','ifOutDiscards','ifInDiscards','ifInErrors','ifHCInOctets','ifHighSpeed','ifSpeed','ifOperStatus','ifAdminStatus','ifOutOctets','ifInOctets')
> 
> NOT NULL,
>  `min` bigint(20) NOT NULL,
>  `max` bigint(20) NOT NULL,
>  `average` bigint(20) NOT NULL,
>  KEY `sampleDate` (`sampleDate`),
>  KEY `interfaceID` (`interfaceID`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
> 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.day << " " 
> << 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.
>
> Thanks,
>
> Rick
>
>
>

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