|
SAP BI Java SDK | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Relational Command Processor allows for the manipulation of a query object on a high level without exposing the underlying model.
The commands are based on the SQL
language, and they should be
relatively straightforward if you have a basic knowledge of SQL
.
WHERE
conditions are specified with an expressions stack in
combination with unary or binary operators. For example, you specify the
... WHERE T1.COL1=1 AND (T1.COL2=2 OR T1.COL3=3)
condition as follows:
pushWhereComparison("T1",col2,IBISQLComparisonOperator.EQUALS, new Integer(3))
pushWhereComparison("T1",col2,IBISQLComparisonOperator.EQUALS, new Integer(2))
pushWhereLogicalOperator(IBISQLLogicalOperator.OR)
pushWhereComparison("T1",col1,IBISQLComparisonOperator.EQUALS, new Integer(1))
pushWhereLogicalOperator(IBISQLLogicalOperator.AND)
WHERE
conditions are essentially binary trees with
binary operators as internal nodes and columns, and values and
subselects as leaves. Binary operators in this sense are opposed to unary
operators such as NOT ...
and ... IS NULL
and
ternary operators such as ... BETWEEN .. AND ...
.
Table aliases (necessary for JOIN
operations) are simple String
references, generated
automatically or user-provided with the addTable(...)
methods.
Method Summary | |
String |
addColumn(org.omg.cwm.resource.relational.Column column)
Adds a column from the table to the result to be retrieved. |
String |
addColumn(org.omg.cwm.resource.relational.Column column,
String tableRef)
Same as addColumn(Column) ,
whereby the column is specified by name and reference to an instance of the table used in
this query. |
String |
addColumn(org.omg.cwm.resource.relational.Column column,
String tableRef,
com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLAggregateFunction aggregateFunction,
String columnRef)
Same as addColumn(Column, String) ,
whereby an aggregation for this column can be supplied in aggregateFunction . |
String |
addColumn(org.omg.cwm.resource.relational.Column column,
String tableRef,
String columnRef)
Same as addColumn(Column, String) ,
whereby the label for this column in the result set is supplied in columnRef
instead of being automatically generated. |
void |
addGroupBy(org.omg.cwm.resource.relational.Column column,
String tableRef)
Groups the result set by the column specified. |
void |
addOrderBy(org.omg.cwm.resource.relational.Column column,
String tableRef)
Orders the result by the column and table reference specified. |
void |
addOrderBy(org.omg.cwm.resource.relational.Column column,
String tableRef,
boolean ascending)
Same as addOrderBy(Column, String) ,
whereby the sort direction is ascending if ascending is true ,
otherwise descending. |
String |
addRowCount(String tableRef)
Adds a row counter to the result set to be retrieved (equivalent to COUNT(*) in SQL ).
|
String |
addRowCount(String tableRef,
String columnRef)
Same as addRowCount(String) ,
whereby the name (label) of column in the result set can be specified in
columnRef . |
String |
addTable(org.omg.cwm.resource.relational.Table table)
Adds a table to the query. |
String |
addTable(org.omg.cwm.resource.relational.Table table,
String tableRef)
Same as addTable(Table) , whereby in this case the
table reference (must be unique for this query) is
supplied in tableRef . |
void |
clear()
Resets the query. |
ResultSet |
execute()
Executes the query (retrieving the result). |
void |
initialize()
Resets the query to its initial (empty) state. |
void |
pushWhereComparison(String tableRef,
org.omg.cwm.resource.relational.Column column,
com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper)
Pushes the comparison on to the WHERE stack. |
void |
pushWhereComparison(String tableRef,
org.omg.cwm.resource.relational.Column column,
com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper,
IBIQuery subselect)
Pushes the comparison on to the WHERE stack. |
void |
pushWhereComparison(String tableRef,
org.omg.cwm.resource.relational.Column column,
com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper,
List values)
Pushes the comparison on to the WHERE stack. |
void |
pushWhereComparison(String tableRef,
org.omg.cwm.resource.relational.Column column,
com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper,
Object value)
Pushes the comparison on to the WHERE stack. |
void |
pushWhereComparison(String tableRef,
org.omg.cwm.resource.relational.Column column,
com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper,
Object[] values)
Pushes the comparison on to the WHERE stack. |
void |
pushWhereComparison(String tableRef,
org.omg.cwm.resource.relational.Column column,
com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper,
String tableRef2,
org.omg.cwm.resource.relational.Column column2)
Pushes the comparison on to the WHERE stack. |
void |
pushWhereLogicalOperator(com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLLogicalOperator oper)
Pushes the logical operator onto the WHERE stack. |
void |
removeColumn(String columnRef)
Removes a column from the query identified by its reference. |
void |
removeTable(String tableRef)
Removes a table from the query identified by its reference. |
void |
removeWhereCondition()
Removes the current WHERE condition. |
void |
synchronize()
Synchronizes the command processor with the query. |
Method Detail |
public void clear() throws BIResourceException
BIResourceException
- if the operation failspublic void synchronize() throws BIResourceException
BIResourceException
- if an error occurs during the generation of the expressionpublic String addColumn(org.omg.cwm.resource.relational.Column column) throws BIResourceException
column
- the column to be addedBIResourceException
- if the column does not belong to a table
that has been previously addedColumn
public String addColumn(org.omg.cwm.resource.relational.Column column, String tableRef) throws BIResourceException
addColumn(Column)
,
whereby the column is specified by name and reference to an instance of the table used in
this query.column
- the column to be addedtableRef
- the table instance to which this column belongsBIResourceException
- if the table reference is unknown or the
column is not part of the referenced tableaddColumn(Column, String)
,
Column
public String addColumn(org.omg.cwm.resource.relational.Column column, String tableRef, String columnRef) throws BIResourceException
addColumn(Column, String)
,
whereby the label for this column in the result set is supplied in columnRef
instead of being automatically generated.column
- the column to be addedtableRef
- the table instance to which this column belongscolumnRef
- the label of this column in the result setBIResourceException
- if the table reference is unknown or the
column is not part of the referenced tableColumn
public String addColumn(org.omg.cwm.resource.relational.Column column, String tableRef, com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLAggregateFunction aggregateFunction, String columnRef) throws BIResourceException
addColumn(Column, String)
,
whereby an aggregation for this column can be supplied in aggregateFunction
.column
- the column to be addedtableRef
- the table instance to which this column belongsaggregateFunction
- the aggregation to be used on this column (for example, SUM)columnRef
- the label of this column in the result setBIResourceException
- if the table reference is unknown or the
column is not part of the referenced tableColumn
public String addRowCount(String tableRef) throws BIResourceException
COUNT(*)
in SQL
).
Notes:
tableRef == null
, the rows of the result set or
of each group of the result set (see addGroupBy(Column, String)
)
are counted.
tableRef != null
, only the rows of
the table referred by tableRef
are counted; in other words,
COUNT(tableRef.*)
instead of COUNT(*)
.
SQL
), only rows that are NOT NULL
are counted. In other words, at least one column of each counted row must be
NOT NULL
.
tableRef
- the table instance to which this counter belongs (can be null
)BIResourceException
- if the table reference is unknownpublic String addRowCount(String tableRef, String columnRef) throws BIResourceException
addRowCount(String)
,
whereby the name (label) of column in the result set can be specified in
columnRef
.tableRef
- the table instance to which this counter belongs (can be null
)columnRef
- the label of this column in the result setBIResourceException
- if the table reference is unknownpublic void addGroupBy(org.omg.cwm.resource.relational.Column column, String tableRef) throws BIResourceException
column
- the column by which the result set is to be groupedtableRef
- the table instance to which this column belongsBIResourceException
- if the table reference is unknown or the
column is not part of the referenced tableColumn
public void addOrderBy(org.omg.cwm.resource.relational.Column column, String tableRef) throws BIResourceException
column
- the column by which the result set is to be sortedtableRef
- the table instance to which this column belongsBIResourceException
- if the table reference is unknown or the
column is not part of the referenced tableColumn
public void addOrderBy(org.omg.cwm.resource.relational.Column column, String tableRef, boolean ascending) throws BIResourceException
addOrderBy(Column, String)
,
whereby the sort direction is ascending if ascending
is true
,
otherwise descending.column
- the column by which the result set is to be sortedtableRef
- the table instance to which this column belongsascending
- is the sort direction ascending?BIResourceException
- if the table reference is unknown or the
column is not part of the referenced tableColumn
public String addTable(org.omg.cwm.resource.relational.Table table) throws BIResourceException
table
- to add to queryBIResourceException
- (unused)Table
public String addTable(org.omg.cwm.resource.relational.Table table, String tableRef) throws BIResourceException
addTable(Table)
, whereby in this case the
table reference (must be unique for this query) is
supplied in tableRef
.table
- to add to querytableRef
- table reference to uniquely identify this table in this
queryBIResourceException
- (unused)Table
public ResultSet execute() throws BIResourceException
BIResourceException
- in case of errors during the executionpublic void initialize() throws BIResourceException
BIResourceException
- (unused)public void pushWhereComparison(String tableRef, org.omg.cwm.resource.relational.Column column, com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper, Object value) throws BIResourceException
WHERE
stack.tableRef
- the table reference to which the column belongscolumn
- the left-hand-side of the comparisonoper
- the comparison operator (value
- the right-hand-side of the comparisonBIResourceException
- if any one of the following conditions exist:
column
is unknown
tableRef
is unknown
column
does not belong to the table referred to by
tableRef
oper
is unknown
value
does not match the type of
column
oper
is not 1
public void pushWhereComparison(String tableRef, org.omg.cwm.resource.relational.Column column, com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper) throws BIResourceException
WHERE
stack.tableRef
- the table reference to which the column belongscolumn
- the left-hand-side of the comparisonoper
- the comparison operator (BIResourceException
- if any one of the following conditions hold
column
is unknown
tableRef
is unknown
column
does not belong to the table referred to by
tableRef
oper
is unknown
oper
is not 0
public void pushWhereComparison(String tableRef, org.omg.cwm.resource.relational.Column column, com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper, Object[] values) throws BIResourceException
WHERE
stack.tableRef
- the table reference to which the column belongscolumn
- the left-hand-side of the comparisonoper
- the comparison operator (values
- the right-hand-side of the comparisonBIResourceException
- if any one of the following conditions hold
column
is unknown
tableRef
is unknown
column
does not belong to the table referred to by
tableRef
oper
is unknown
values
does not
match the type of column
oper
is not
values.length
public void pushWhereComparison(String tableRef, org.omg.cwm.resource.relational.Column column, com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper, List values) throws BIResourceException
WHERE
stack.tableRef
- the table reference to which the column belongscolumn
- the left-hand-side of the comparisonoper
- the comparison operator (values
- the right-hand-side of the comparisonBIResourceException
- if any one of the following conditions hold
column
is unknown
tableRef
is unknown
column
does not belong to the table referred to by
tableRef
oper
is unknown
values
does not match
the type of column
oper
is not
values.size()
public void pushWhereComparison(String tableRef, org.omg.cwm.resource.relational.Column column, com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper, IBIQuery subselect) throws BIResourceException
WHERE
stack.tableRef
- the table reference to which the column belongscolumn
- the left-hand-side of the comparisonoper
- the comparison operator (subselect
- A query with 1 column selected the type of which matches
the left-hand-side of the comparisonBIResourceException
- if any one of the following conditions hold
column
is unknown
tableRef
is unknown
column
does not belong to the table referred to
by tableRef
oper
is unknown
subselect
does not match
the type of column
oper
can not handle sub-selects
public void pushWhereComparison(String tableRef, org.omg.cwm.resource.relational.Column column, com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLComparisonOperator oper, String tableRef2, org.omg.cwm.resource.relational.Column column2) throws BIResourceException
WHERE
stack.tableRef
- the table reference to which the column belongscolumn
- the left-hand-side of the comparisonoper
- the comparison operator (tableRef2
- the table reference to which the column belongscolumn2
- the right-hand-side of the comparisonBIResourceException
- if any one of the following conditions hold
column
is unknown
tableRef
is unknown
column
does not belong to the table referred to by
tableRef
column2
is unknown
tableRef2
is unknown
column2
does not belong to the table referred to by
tableRef2
oper
is unknown
column
does
not match the type of column2
oper
is not a comparison operator
public void pushWhereLogicalOperator(com.sap.ip.bi.sdk.dac.relational.query.sql.IBISQLLogicalOperator oper) throws BIResourceException
WHERE
stack.oper
- logical operator (BIResourceException
- if the operator is unknown or the stack does
not contain the appropriate operands for this operatorpublic void removeColumn(String columnRef) throws BIResourceException
columnRef
- reference to the column to be removedBIResourceException
- if the column reference is unknownColumn
public void removeTable(String tableRef) throws BIResourceException
tableRef
- reference to table instance to be removedBIResourceException
- if table reference is not part of queryTable
public void removeWhereCondition() throws BIResourceException
WHERE
condition.BIResourceException
- unused
|
SAP BI Java SDK | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |