[odb-users] Prepared query for native queries

Wolfgang Haupt haupt.wolfgang at gmail.com
Sat Mar 9 04:54:18 EST 2019


Hi,

2 things come into my mind:

* Try again without prepare_query (if it's not essential to you)
* Make sure you've compiled with "--generate-prepared"

BR
Wolfgang

On 2019-03-09 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