[odb-users] Defining a table view with inner join

Lior Tamim liorta at gmail.com
Sun Jan 21 01:40:18 EST 2018


I followed the manual and ended up with this:
#pragma db view table("developers") table("new_employees" inner:
"developers.employee_id"
== "new_employees.id")

But odb compilation fails on the 'inner' keyword:
error: ')' expected at the end of db pragma table

I'm not sure why, because this statement follows the same rules as this one
(from the manual):
#pragma db view object(employer) object(country inner: employer::name ==
country::name)

What am I missing?

On Fri, Jan 19, 2018 at 2:26 PM, Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Lior Tamim <liorta at gmail.com> writes:
>
> > Suppose I have 2 database tables:
> >
> > CREATE TABLE developers(
> >     employee_id INTEGER,
> >     employee_name TEXT)
> >
> > CREATE TABLE new_employees(
> >     id INTEGER,
> >     age INTEGER)
> >
> > I wish to define a table view that contains all the *new developers*.
> >
> > With simple SQL query this can be achieved easily by using inner join:
> > "select * from developers inner join new_employees on
> > developers.employee_id == new_employees.id"
> >
> > What's the best way to achieve this with table view pragma?
> >
> > #pragma db view table("developers" ...) // not sure how to continue this
>
> Section 10.3, "Table Views" in the manual deals with this pretty
> comprehensively, including an example that does pretty much
> exactly this (sans the inner join, but it should be fairly
> clear where to put it from the general format discussed a
> couple of paragraphs above).
>


More information about the odb-users mailing list