Bug #6103
closedError when quering from db from 2 widgets
0%
Description
Hi,
When i want to update 2nd widget after 1st widget transaction is commited and signal is emitted from 1st (after commit), i get this error in 2nd widget:
@ dbo::Session& session = PlannerApplication::plannerApplication()->session;
dbo::Transaction transaction(session);
typedef dbo::collection<dbo::ptr > Entries;
Entries entries = user->entriesInRange(date.addDays(--10), date ); // place where i get error@
error:
Wt: error during event handling: A collection for 'select count(1) from (select ""id"", ""version"", ""user_id"", ""date"", ""start"", ""stop"", ""summary"", ""text"" from ""entry"" where (""user_id"" = ?) and (start >= ?) and (start < ?))' is already in use. Reentrant statement use is not yet implemented.\"
Updated by Grzesiek Buraczewski about 7 years ago
I find a way, I could emit signal before quering for 1st widget update. But it feels wrong that I have to updated 2nd first and first second and I dont know why ??
Updated by Grzesiek Buraczewski about 7 years ago
I think its because I cant emit signals in transactions. Am I right ??
Updated by Roel Standaert about 7 years ago
You certainly can emit signals in transactions. Wt::Dbo
and Wt
for the most part work independently, except for some Dbo
-specific features in Wt
.
The reason why this happens is because Wt::Dbo
at the moment does not support using the same SQL prepared statement twice for a certain connection. Do you have another Entries
collection around at the same time? Or another very similar query?
There are several ways that you can prevent this from happening, e.g. you can first copy the collection
into an STL container, freeing the underlying query, see the documentation for Wt::Dbo::collection
.
Updated by Grzesiek Buraczewski about 7 years ago
Yes, both are true I had one Entries that is the above (querying for 10 past day ) and 2nd Entries from different widget but I think (querying for 7 days forward). I tought that collection is kind of STL container, by bad.
Thanks.
Updated by Roel Standaert about 7 years ago
Yeah, Wt::Dbo::collection
is not quite like an STL container, it behaves more like a cursor over the results of a query.