[odb-users] Prepared query for native queries
Lisa Fiedler
lfiedler at informatik.uni-leipzig.de
Sat Mar 9 05:05:01 EST 2019
Hello,
I am sorry, it compiles now. I did not properly save the updated
makefile with the --generate-prepared option.
Thanks all the same
On 09.03.19 10:13, Lisa Fiedler wrote:
> Hello,
>
> I was trying to use prepared native prepared query.
>
> For this purpose I created a native view:
>
> #pragma db view struct queryCount_view{ #pragma db type("BIGINT")
> u_int64_t count; };
>
> and then tried the following:
>
> odb::connection_ptr conn(db->connection());
> uint64_t weight; odb::query<queryCount_view> q ("SELECT \"record\"
> FROM complete.\"edge_attributes\" WHERE \"weigth\" ='" +
> to_string(weight) + "' )"); odb::prepared_query<queryCount_view> p
> (conn->prepare_query<queryCount_view>("test_query",q));
> weight = 8; odb::transaction t (db->begin());
> odb::result<queryCount_view> r(p.execute()); for(auto it =
> r.begin(); it != r.end(); it++){ cout << it->count <<
> endl; } t.commit();
>
> This did not work out however, with the error message:
>
> error: ‘prepare_query’ is not a member of
> ‘odb::view_traits_impl<queryCount_view, (odb::database_id)5>’
>
> view_traits_impl<T, DB>::prepare_query (c, n, q));
>
> Please note, that this was merely a simple test scenario and is not
> actually the query I want to pose. I was just trying to find out how
> to conduct prepared native queries.
>
> Is there some other way to realize this?
>
> Thank you!
>
More information about the odb-users
mailing list