Outer join by referencing. More...
Public Member Functions
|Public Member Functions inherited from RDM::DB::QUERY::join_rows< table_id, NEXT >|
|uint32_t||init_tables_to_write_lock (RDM_TABLE_ID *tables)|
|IDs of the tables where rows are inserted. More...
|uint32_t||init_tables_to_read_lock (RDM_TABLE_ID *tables)|
|IDs of the tables where rows are read. More...
|RDM_RETCODE||init (RDM_DB db)|
|Initialize this object. More...
|Reset this object. More...
|Fetch the first. More...
|Fetch the previous. More...
|Fetch the next. More...
|Fetch the last. More...
|template<class TARGET_ROW_T >|
|RDM_RETCODE||bind_row (TARGET_ROW_T *target_row, bool *target_all_columns_null=NULL)|
|Bind a row. More...
Additional Inherited Members
|Static Public Member Functions inherited from RDM::DB::QUERY::join_rows< table_id, NEXT >|
|constexpr static int||number_of_tables_to_write_lock (void)|
|Number of tables where rows are inserted. More...
|constexpr static int||number_of_tables_to_read_lock (void)|
|Number of tables where rows are read. More...
|Data Fields inherited from RDM::DB::QUERY::join_rows< table_id, NEXT >|
|Protected Attributes inherited from RDM::DB::QUERY::join_rows< table_id, NEXT >|
template<RDM_TABLE_ID table_id, RDM_REF_ID ref_id, class NEXT>
class RDM::DB::QUERY::outer_join_by_referencing< table_id, ref_id, NEXT >
Outer join by referencing.
Use this template class in combination with other classes for doing an outer join. In its simplest form, the NEXT class is a read_row class, in which case this class implements a join between two tables.
Assuming the following schema:
where we want to compute the natural right outer join between T1 and T2, it can be set up as follows:
We have a chain of two classes. The first class in the chain is a static instanse of the outer_join_by_referencing template class (join), and the next (and last) class in the chain is a static instance of the read_row template class (join.next). Note that for the query to work as intended, the reference has to be from T2.i2 to T1.i2.
Use the init() methode on the first class to initialize these classes with a database handle. Then bind a row for each class by calling bind_row() on both.
This join can be fetched by repeatedly calling fetch_next() until sENDOFCURSOR is returned. For each call, the rows that have been bound will be populated with the actual row data.
The NEXT class can instead be an instance of any of the join template classes, in which case this class implements a join between the result of another join and the table specified here.
Note that there is asymmetry between the arguments of the join. One argument is the computation done by the next class while the other argument is just specified by a table ID. It means this class is not able to implement a join of two row sets where each set itself is a join.
Also note that a join as specified by the SQL standard has a left and a right argument. The two arguments here are the next class in the chain and the table specified. Which argument represents the left and the right argument is up to the application. However, if it is an outer join, it is the next class that represents the outer argument.
- Template Parameters
table_id The ID of the table we join with. This is one argument of the join. ref_id The ID of the reference NEXT The next class in the chain of classes. This represents one arguments of the join.
Constructor & Destructor Documentation
References RDM::DB::QUERY::join_rows< table_id, NEXT >::outer_join.
The documentation for this class was generated from the following file: