List:MySQL++« Previous MessageNext Message »
From:Mathieu Pagé Date:November 14 2006 1:29am
Subject:Re: Exception of type std::length_error
View as plain text  
Warren Young a écrit :
> Mathieu Pagé wrote:
>>
>> <code>
>> mysqlpp::Row row;
>> mysqlpp::Row::size_type i;
>> for (i = 0; row = res.at(i); ++i)
>>   cout <<row.at(0) <<endl;
>> </code>
>>
>> however I get an length_error exception on "row = res.at(i)".
>
> I think you're expecting Row::at() to return false (or, rather, an 
> object that can be converted to false) when you walk off the end of 
> the result set.  MySQL++ doesn't do that sort of thing, by design.  It 
> signals errors with exceptions, just as you saw.
>
> That is the fall-back behavior when you turn off exceptions, however. 
> Read the user manual for details.
>
> You might also look at examples/simple3.cpp.  It operates in a way 
> very similar to what you're doing, without needing special treatment.  
> It does that by using a different type of query than you are using.
>
Hi M. Young

Thanks you for your answer.

I looked at simple.cpp and tried to do the same thing in my code (using 
"res.fetch_row()") and I got the same error. Actually I just realised, 
looking at the stack trace when the error occurs, that the exception is 
trown during the execution of the operator= function that copy the row.

I also tried to execute example/resetdb tonight and it raise an 
exception too. Maybe there is a problem with my compiled version of MySQL++.
Thread
Exception of type std::length_errorMathieu Pagé13 Nov
  • Re: Exception of type std::length_errorWarren Young14 Nov
    • Re: Exception of type std::length_errorMathieu Pagé14 Nov
Re: Exception of type std::length_errorMathieu Pagé19 Nov
  • Re: Exception of type std::length_errorWarren Young20 Nov
    • Running Totals with MySQLKerry Frater21 Nov
      • RE: Running Totals with MySQLKerry Frater21 Nov
      • Re: Running Totals with MySQLWarren Young22 Nov
        • RE: Running Totals with MySQLKerry Frater28 Nov