public abstract class DBCommandExpr extends DBExpr
Modifier and Type | Class and Description |
---|---|
protected static class |
DBCommandExpr.DBCmdColumn
This class wraps a column of sql command in a special command column object.
|
protected static class |
DBCommandExpr.DBCmdQuery |
Modifier and Type | Field and Description |
---|---|
protected DBCommandExpr.DBCmdQuery |
cmdQuery |
protected List<DBOrderByExpr> |
orderBy |
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESIS, CTX_VALUE
Constructor and Description |
---|
DBCommandExpr(DBMSHandler dbms)
Constructs an empty DBCommandExpr object
|
Modifier and Type | Method and Description |
---|---|
protected void |
addListExpr(DBSQLBuilder sql,
List<? extends DBExpr> list,
long context,
String separator)
Internally used to build a string from a list of database expressions
|
void |
addSQL(DBSQLBuilder sql,
long context)
Creates the SQL-Command.
|
void |
clearLimit()
Clears a limit or offset set by calling limit() or offset()
|
void |
clearOrderBy()
Clears the list of order by expressions.
|
DBCommandExpr |
clone()
Creates a clone of this class.
|
protected DBSQLBuilder |
createSQLBuilder(String initalSQL)
creates a new DBSQLBuilder
|
protected DBColumnExpr |
getCmdColumn(DBColumnExpr col)
wraps a column expression such that is specific for to this command and detached from its source.
|
abstract DataType |
getDataType()
Returns the DataType selected by this command if only one column is returned
If the command has more than one select expression DataType.UNKNOWN will be returned
|
DBMSHandler |
getDbms()
returns the DBMSHandler this command belongs to
|
String |
getInsertInto(DBTable table)
Create the insert into SQL-Command which copies
data from a select statement to a destination table.
|
protected String |
getInsertInto(DBTable table,
DBColumnExpr[] select,
List<DBColumnExpr> columns)
Create the insert into SQL-Command which copies data
from a select statement to a destination table.
|
String |
getInsertInto(DBTable table,
List<DBColumnExpr> columns)
Create the insert into SQL-Command which copies
data from a select statement to a destination table.
|
List<DBOrderByExpr> |
getOrderBy()
Returns a copy of the defined order-bys.
|
abstract DBCmdParams |
getParams() |
abstract Object[] |
getParamValues()
returns an array holding all parameter values in the order of their occurrence.
|
String |
getSelect()
returns an SQL select command for querying records.
|
abstract void |
getSelect(DBSQLBuilder sql)
returns an SQL select command
|
abstract List<DBColumnExpr> |
getSelectExpressions()
returns a list of expressions for the SELECT part of the sql statement
|
abstract DBColumnExpr[] |
getSelectExprList()
Returns the list of all select expressions as an array
Used internally only
|
boolean |
hasOrderBy()
Returns whether or not the command has order by set
|
abstract boolean |
hasSelectExpr()
returns whether or not the command has any select expression
|
abstract boolean |
hasSelectExpr(DBColumnExpr expr)
returns whether or not the command has a specific select expression
|
DBCommandExpr |
intersect(DBCommandExpr other)
Constructs a new DBCombinedCmd object with this object,
the key word= "INTERSECT" and the selected DBCommandExpr.
|
abstract boolean |
isValid() |
DBCommandExpr |
limitRows(int numRows)
set the maximum number of rows to return when executing a query command
A negative value will remove the limit.
|
DBCommandExpr |
orderBy(DBColumnExpr... exprs)
Adds a list of columns to the orderBy clause in ascending order
|
DBCommandExpr |
orderBy(DBColumnExpr expr,
boolean desc)
Adds an order by with ascending or descending order
|
DBCommandExpr |
orderBy(DBOrderByExpr... exprs)
Adds an order by expression the command
|
DBColumnExpr |
result()
Returns a ColumnExpr for the result of the query
If the command must have exactly one select column otherwise a NotSupportedException is thrown;
|
DBCommandExpr |
skipRows(int numRows)
sets the offset of the first row to return when executing a query command.
|
DBCommandExpr |
union(DBCommandExpr other)
Constructs a new DBCombinedCmd object with this object,
the key word= "UNION" and the selected DBCommandExpr.
|
DBCommandExpr |
unionAll(DBCommandExpr other)
Constructs a new DBCombinedCmd object with this object,
the key word= "UNION ALL" and the selected DBCommandExpr.
|
addReferencedColumns
checkParamNull, getDatabase
protected DBCommandExpr.DBCmdQuery cmdQuery
protected List<DBOrderByExpr> orderBy
public DBCommandExpr(DBMSHandler dbms)
dbms
- the database handlerpublic final DBMSHandler getDbms()
public DBCommandExpr clone()
public abstract boolean isValid()
public abstract boolean hasSelectExpr()
public abstract boolean hasSelectExpr(DBColumnExpr expr)
expr
- the column exprpublic abstract DBColumnExpr[] getSelectExprList()
public abstract List<DBColumnExpr> getSelectExpressions()
public abstract void getSelect(DBSQLBuilder sql)
sql
- the sql builder to add the command topublic final String getSelect()
public abstract DBCmdParams getParams()
public abstract Object[] getParamValues()
public abstract DataType getDataType()
public DBColumnExpr result()
public void addSQL(DBSQLBuilder sql, long context)
public DBCommandExpr union(DBCommandExpr other)
other
- the second DBCommandExprDBCombinedCmd
public DBCommandExpr unionAll(DBCommandExpr other)
other
- the second DBCommandExprDBCombinedCmd
public DBCommandExpr intersect(DBCommandExpr other)
other
- the second DBCommandExprpublic boolean hasOrderBy()
public List<DBOrderByExpr> getOrderBy()
public void clearOrderBy()
public DBCommandExpr orderBy(DBOrderByExpr... exprs)
exprs
- vararg of orderBy expressionsorderBy(DBColumnExpr, boolean)
public DBCommandExpr orderBy(DBColumnExpr... exprs)
exprs
- vararg of column expressionspublic DBCommandExpr orderBy(DBColumnExpr expr, boolean desc)
expr
- the DBColumnExpr objectdesc
- if true, the results from select statement will sort top downpublic DBCommandExpr limitRows(int numRows)
numRows
- the number of rows to limitpublic DBCommandExpr skipRows(int numRows)
numRows
- the number of rows to skippublic void clearLimit()
public final String getInsertInto(DBTable table, List<DBColumnExpr> columns)
table
- the tablecolumns
- the columnspublic final String getInsertInto(DBTable table)
table
- the tableprotected DBSQLBuilder createSQLBuilder(String initalSQL)
initalSQL
- protected DBColumnExpr getCmdColumn(DBColumnExpr col)
col
- the column expression to wrapprotected void addListExpr(DBSQLBuilder sql, List<? extends DBExpr> list, long context, String separator)
sql
- the sql target bufferlist
- the list of expressions to add to the sqlcontext
- the sql command contextseparator
- string to use as separator between list itemsprotected String getInsertInto(DBTable table, DBColumnExpr[] select, List<DBColumnExpr> columns)
table
- the table to insertselect
- the selected columnscolumns
- the list of column expressionsCopyright © 2008–2023 Apache Software Foundation. All rights reserved.