Outer join by key. More...
#include "rdm_db_query.h"


Public Member Functions |
|
outer_join_by_key () | |
![]() |
|
RDM_RETCODE | bind_key (void *key_ref1, void *key_ref2=NULL, void *key_ref3=NULL, void *key_ref4=NULL, void *key_ref5=NULL, void *key_ref6=NULL, void *key_ref7=NULL, void *key_ref8=NULL, void *key_ref9=NULL, void *key_ref10=NULL) |
Bind a key. More... |
|
![]() |
|
join_rows () | |
~join_rows () | |
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... |
|
void | reset (void) |
Reset this object. More... |
|
RDM_RETCODE | fetch_first () |
Fetch the first. More... |
|
RDM_RETCODE | fetch_prev () |
Fetch the previous. More... |
|
RDM_RETCODE | fetch_next () |
Fetch the next. More... |
|
RDM_RETCODE | fetch_last () |
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 |
|
![]() |
|
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... |
|
![]() |
|
NEXT | next |
![]() |
|
join_by_key () | |
![]() |
|
RDM_DB | db |
RDM_CURSOR | cursor |
void * | target_row |
uint32_t | target_size |
bool * | target_all_columns_null |
bool | outer_join |
position | pos |
Detailed Description
template<RDM_TABLE_ID table_id, RDM_KEY_ID key_id, class KEY_T, class NEXT>
class RDM::DB::QUERY::outer_join_by_key< table_id, key_id, KEY_T, NEXT >
Outer join by key.
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 join between T1 and T2, it can be set up as follows:
We have a chain of two classes above. The first class in the chain is a static instanse of the outer_join_by_key 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 key has to be on T2.i2. No key is required for 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. Lastly, the key would be bound by calling bind_key() for the first class where the actual parameter is a reference to i2 of the bound row of the second class.
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. key_id The ID of the key we key on KEY_T The class type for the key NEXT The next class in the chain of classes. This represents one arguments of the join.
Constructor & Destructor Documentation
outer_join_by_key()
|
inline |
The documentation for this class was generated from the following file: