[odb-users] ODB without persistent objects?
boris at codesynthesis.com
Mon Jul 14 09:41:54 EDT 2014
Sorry for the late reply. You email was caught up by the spam
filter and it took me a while to detect this.
frankiegp at libero.it <frankiegp at libero.it> writes:
> I would like to know whether I could exploit ODB Query functionalities
> without creating any C++ classes to be mapped to the tables of a
> database. I mean:
> - I have an existent database managed by a hypothetical DBMS (one among
> PostgreSQL, MySQL, Oracle, SQLServer and so on);
> - I would like to query my database without taking care of the specific
> dialect of the DBMS.
> In other words, I would like to write my queries in some high-level
> languages (pseudo-sql) and then I would like that my query would be
> rewritten by ODB in the SQL-dialect of the specific DBMS. Is it possible?
You can use ODB Table Views for that (Section 10.2, "Table Views" in the
ODB manual). You will get result extraction into C++ types as well as
query parameter binding (_val()/_ref). What you won't get is C++ names
for column names as you get with objects. So instead of having this:
query::name == "Jonh" && query::age == 18
You will have to write:
"name = " + query::_val ("John") + "AND age = " + query::_val (18)
If you want to get the first variant, what you can do is still map
tables to objects but mark them read-only (Section 14.1.4, "readonly").
Then you can use such objects for queries or use them to create object
More information about the odb-users