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_NOPARENTHESES, CTX_VALUE
Constructor and Description |
---|
DBCommandExpr()
Constructs an empty DBCommandExpr object
|
Modifier and Type | Method and Description |
---|---|
protected void |
addListExpr(StringBuilder buf,
List<? extends DBExpr> list,
long context,
String separator)
Internally used to build a string from a list of database expressions
|
void |
addSQL(StringBuilder buf,
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.
|
protected DBColumnExpr |
getCmdColumn(DBColumnExpr col)
returns column expression that is specific for to this command and detached from its source.
|
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.
|
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(StringBuilder buf) |
abstract DBColumnExpr[] |
getSelectExprList() |
DBCommandExpr |
intersect(DBCommandExpr other)
Constructs a new DBCombinedCmd object with this object,
the key word= "INTERSECT" and the selected DBCommandExpr.
|
abstract boolean |
isValid() |
void |
limitRows(int numRows)
set the maximum number of rows to return when executing a query command
A negative value will remove the limit.
|
void |
orderBy(DBColumnExpr... exprs)
Adds a list of columns to the orderBy clause in ascending order
|
void |
orderBy(DBColumnExpr expr,
boolean desc)
Adds an order by with ascending or descending order
|
void |
orderBy(DBOrderByExpr... exprs)
Adds an order by expression the command
|
void |
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, getObjectValue, getValueClass
getDatabase
protected DBCommandExpr.DBCmdQuery cmdQuery
protected List<DBOrderByExpr> orderBy
public abstract boolean isValid()
public abstract void getSelect(StringBuilder buf)
public abstract DBColumnExpr[] getSelectExprList()
public abstract Object[] getParamValues()
protected DBColumnExpr getCmdColumn(DBColumnExpr col)
public final String getSelect()
protected void addListExpr(StringBuilder buf, List<? extends DBExpr> list, long context, String separator)
buf
- the sql target bufferlist
- list of database objectscontext
- the sql command contextseparator
- string to use as separator between list itemspublic void addSQL(StringBuilder buf, 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 void clearOrderBy()
public void orderBy(DBOrderByExpr... exprs)
exprs
- vararg of orderBy expressionsorderBy(DBColumnExpr, boolean)
public void limitRows(int numRows)
public void skipRows(int numRows)
public void clearLimit()
public final void orderBy(DBColumnExpr... exprs)
exprs
- vararg of column expressionspublic final void orderBy(DBColumnExpr expr, boolean desc)
expr
- the DBColumnExpr objectdesc
- if true, the results from select statement will sort top downprotected String getInsertInto(DBTable table, DBColumnExpr[] select, List<DBColumnExpr> columns)
public final String getInsertInto(DBTable table, List<DBColumnExpr> columns)
table
- the tablecolumns
- the columnsCopyright © 2008–2018 Apache Software Foundation. All rights reserved.