[odb-users] Using CTEs in ODB queries

Boris Kolpackov boris at codesynthesis.com
Mon Aug 8 11:53:17 EDT 2016


Hi,

Whisperity <whisperity at gmail.com> writes:

> I assume the same patch has been added to libodb-sqlite as well?

Now it has. Thanks for checking.


> What I was trying to achieve is this. I have a RESULT table (so there is no
> persistent type for it) of two columns which are two IDs calculated by the
> query. But actually this table defines a relationship of an object having
> the ID from the first column to many objects having IDs from the second
> column.
> 
> So instead of doing "SELECT id1, id2 FROM cte;" and loading them as just
> pairs of IDs, I thought I could let ODB do the grouping job for me and my
> code would only get struct which contains an int and a vector(/set) of ints.

No, you cannot currently do this. The closest would probably be a view
that contains both IDs and you return them ORDER'ed BY the first ID.
So you get ranges of view objects that correspond to the same first ID.

Boris



More information about the odb-users mailing list