[odb-users] Query Result Problem

Erez Pics picserez at gmail.com
Fri Sep 25 10:27:54 EDT 2015


 Hi Boris,

Thank you for your answer, I did research the manual, it seems that to
perform an inner join I need to add the "inner" right after the second
table and before the ":"

But I got an error : 'error: ')' expected at the end of db pragma
object', maybe I am missing something,

The only change I did was adding the inner directive, this is what I mean:

//////////////////////////////////////////////////////
// this is the original ODB syntax [works by ODB compiler]
//////////////////////////////////////////////////////
#pragma db view object(CPersonSet) \
object(CPersonLangData: CPersonSet::m_person_set_id ==
CPersonLangData::m_person_set_id) \
query((?) + "GROUP BY" + CPersonLangData::m_data_language)
struct view_persons_per_langauges
{
#pragma db column(CPersonLangData::m_data_language)
int data_language;

#pragma db column("count (distinct " + CPersonSet::m_person_id + ")")
long count_persons;
};

//////////////////////////////////////////////////////
// this is the original ODB syntax [with inner directive, ODB compiler
gives an error]
//////////////////////////////////////////////////////
#pragma db view object(CPersonSet) \
object(CPersonLangData inner: CPersonSet::m_person_set_id ==
CPersonLangData::m_person_set_id) \
query((?) + "GROUP BY" + CPersonLangData::m_data_language)
struct view_persons_per_langauges
{
#pragma db column(CPersonLangData::m_data_language)
int data_language;

#pragma db column("count (distinct " + CPersonSet::m_person_id + ")")
long count_persons;
};

Thank you,
Erez.


On Fri, Sep 25, 2015 at 4:58 PM, Boris Kolpackov
<boris at codesynthesis.com> wrote:
> Hi Erez,
>
> Erez Pics <picserez at gmail.com> writes:
>
>> I am unsure how to make this an inner join instead of the default left
>> join, the ODB compiler does not approve the syntax I use, can you
>> please advice how to make the view to be an inner join ?
>
> Just search the manual. Is it really easier to write an email than
> open the manual, hit Ctrl-F, and type "inner join"? There is even
> an example:
>
> #pragma db view object(employer) \
>   object(country inner: employer::name == country::name)
> struct employer_named_country
> {
>   shared_ptr<employer> e;
>   shared_ptr<country> c;
> };
>
> Boris



More information about the odb-users mailing list