Re: [Cppcms-users] Bizarre prepared statement problem
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2012-05-22 17:02:28
|
----- Original Message -----
> From: Artyom Beilis <art...@ya...>
> To: "cpp...@li..." <cpp...@li...>
> Cc:
> Sent: Tuesday, May 22, 2012 7:58 PM
> Subject: Re: [Cppcms-users] Bizarre prepared statement problem
>
>
>
>> cppdb::result Base::get_all_items(...)
>
>> {
>>
>> cppdb::result r;
>> string ts = "2012-05-17 23:59:59";
>> ...
>> r=sql ....
>> << date_limited_only
>> << ts
>> << ts
>> << ts
>> << aircraft_id;
>>
>> return r; // <----
>> }
>>
>
> And than in some other place
>
> r = get_all_times(...)
> while(r.next())
> ...
>
> In the first request of r.next() the query is actually
> executed, when **ts** goes out of the scope and becomes invalid.
> and during query the ts is not valid.
>
> That is why it does not work.
>
> I can suggest switch to:
>
> get_all_times
> {
> r = sql ....
> r.next();
> return r;
>
> }
>
> r=get_all_times();
>
> while(!r.empty()) {
> r >> ...
> r.next()
> }
>
> Artyom Beilis
>
On the second thought...
It is bug because it is really unexpected behavior..
And stuff like this
r = sql << "SELECT ... ? .. " << (a+b);
while(r.next()) {
}
Would not work properly
Please open a bug report with HIGH priority
Thanks for the enlightenment!
Artyom
|