|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object mondrian.rolap.sql.SqlQuery.Dialect
public static class SqlQuery.Dialect
Description of a SQL dialect. It is immutable.
Constructor Summary | |
---|---|
SqlQuery.Dialect(String quoteIdentifierString,
String productName,
String productVersion,
Set<List<Integer>> supportedResultSetTypes,
boolean readOnly,
int maxColumnNameLength)
|
Method Summary | |
---|---|
protected boolean |
allowsAs()
Returns whether the SQL dialect allows "AS" in the FROM clause. |
boolean |
allowsCompoundCountDistinct()
Returns whether this Dialect allows multiple arguments to the COUNT(DISTINCT ...) aggregate function, for example
|
boolean |
allowsCountDistinct()
Returns whether this Dialect supports distinct aggregations. |
boolean |
allowsDdl()
Returns whether this dialect supports common SQL Data Definition Language (DDL) statements such as CREATE TABLE and
DROP INDEX . |
boolean |
allowsFromQuery()
Returns whether this Dialect allows a subquery in the from clause, for example SELECT * FROM (SELECT * FROM t) AS x |
boolean |
allowsMultipleCountDistinct()
Returns whether this Dialect supports more than one distinct aggregation in the same query. |
boolean |
allowsMultipleDistinctSqlMeasures()
Returns whether this Dialect has performant support of distinct SQL measures in the same query. |
boolean |
allowsOrderByAlias()
Returns true if aliases defined in the SELECT clause can be used as expressions in the ORDER BY clause. |
String |
caseWhenElse(String cond,
String thenExpr,
String elseExpr)
|
static SqlQuery.Dialect |
create(DatabaseMetaData databaseMetaData)
Creates a SqlQuery.Dialect from a DatabaseMetaData . |
static SqlQuery.Dialect |
create(DataSource dataSource)
Creates a SqlQuery.Dialect from a
DataSource . |
String |
forceNullsCollateLast(String expr)
Modifies an expression in the ORDER BY clause to ensure that NULL values collate after all non-NULL values. |
String |
generateInline(List<String> columnNames,
List<String> columnTypes,
List<String[]> valueList)
Generates a SQL statement to represent an inline dataset. |
int |
getMaxColumnNameLength()
Returns the maximum length of the name of a database column or query alias allowed by this dialect. |
String |
getQuoteIdentifierString()
Returns the character which is used to quote identifiers, or null if quoting is not supported. |
boolean |
isAccess()
|
boolean |
isAS400()
|
boolean |
isCloudscape()
|
boolean |
isDB2()
|
boolean |
isDerby()
|
boolean |
isFirebird()
Returns whether the underlying database is Firebird. |
boolean |
isInformix()
Returns whether the underlying database is Informix. |
boolean |
isIngres()
Returns whether the underlying database is Ingres. |
boolean |
isInterbase()
Returns whether the underlying database is Interbase. |
boolean |
isLucidDB()
Returns whether the underlying database is LucidDB. |
boolean |
isMSSQL()
Returns whether the underlying database is Microsoft SQL Server. |
boolean |
isMySQL()
Returns whether the underlying database is MySQL. |
boolean |
isNullsCollateLast()
Returns whether NULL values appear last when sorted using ORDER BY. |
boolean |
isOldAS400()
|
boolean |
isOracle()
Returns whether the underlying database is Oracle. |
boolean |
isPostgres()
Returns whether the underlying database is Postgres. |
boolean |
isSybase()
Returns whether the underlying database is Sybase. |
boolean |
isTeradata()
Returns whether the underlying database is Teradata. |
void |
quote(StringBuilder buf,
Object value,
SqlQuery.Datatype datatype)
Appends to a buffer a value quoted for its type. |
void |
quoteBooleanLiteral(StringBuilder buf,
String value)
Appends to a buffer a boolean literal. |
void |
quoteDateLiteral(StringBuilder buf,
String value)
Appends to a buffer a date literal. |
String |
quoteIdentifier(String val)
Encloses an identifier in quotation marks appropriate for the current SQL dialect. |
void |
quoteIdentifier(StringBuilder buf,
String... names)
Appends to a buffer a list of identifiers, quoted appropriately for this Dialect. |
String |
quoteIdentifier(String qual,
String name)
Encloses an identifier in quotation marks appropriate for the current SQL dialect. |
void |
quoteIdentifier(String val,
StringBuilder buf)
Appends to a buffer an identifier, quoted appropriately for this Dialect. |
void |
quoteNumericLiteral(StringBuilder buf,
String value)
Appends to a buffer a numeric literal. |
void |
quoteStringLiteral(StringBuilder buf,
String s)
Appends to a buffer a single-quoted SQL string. |
void |
quoteTimeLiteral(StringBuilder buf,
String value)
Appends to a buffer a time literal. |
void |
quoteTimestampLiteral(StringBuilder buf,
String value)
Appends to a buffer a timestamp literal. |
boolean |
requiresAliasForFromQuery()
Returns whether this Dialect requires subqueries in the FROM clause to have an alias. |
boolean |
requiresOrderByAlias()
Returns true if this Dialect can include expressions in the ORDER BY clause only by adding an expression to the SELECT clause and using its alias. |
boolean |
supportsGroupByExpressions()
Returns whether this Dialect supports expressions in the GROUP BY clause. |
boolean |
supportsGroupingSets()
Returns whether this Dialect allows the GROUPING SETS construct in the GROUP BY clause. |
boolean |
supportsMultiValueInExpr()
Returns true if this dialect supports multi-value IN expressions. |
boolean |
supportsResultSetConcurrency(int type,
int concurrency)
Returns whether this Dialect supports the given concurrency type in combination with the given result set type. |
boolean |
supportsUnlimitedValueList()
Returns whether this Dialect places no limit on the number of rows which can appear as elements of an IN or VALUES expression. |
String |
toString()
|
String |
toUpper(String expr)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
SqlQuery.Dialect(String quoteIdentifierString, String productName, String productVersion, Set<List<Integer>> supportedResultSetTypes, boolean readOnly, int maxColumnNameLength)
Method Detail |
---|
public static SqlQuery.Dialect create(DatabaseMetaData databaseMetaData)
SqlQuery.Dialect
from a DatabaseMetaData
.
public static SqlQuery.Dialect create(DataSource dataSource)
SqlQuery.Dialect
from a
DataSource
.
NOTE: This method is not cheap. The implementation gets a connection from the connection pool.
public boolean isAccess()
public boolean isDerby()
public boolean isCloudscape()
public boolean isDB2()
public boolean isAS400()
public boolean isOldAS400()
public String toUpper(String expr)
expr
into upper case.public String caseWhenElse(String cond, String thenExpr, String elseExpr)
public String quoteIdentifier(String val)
quoteIdentifier("emp")
yields a string containing
"emp"
in Oracle, and a string containing
[emp]
in Access.
public void quoteIdentifier(String val, StringBuilder buf)
val
- identifier to quote (must not be null).buf
- Bufferpublic String quoteIdentifier(String qual, String name)
quoteIdentifier("schema","table")
yields a string
containing "schema"."table"
.
qual
- Qualifier. If it is not null,
"qual".
is prepended.name
- Name to be quoted.public void quoteIdentifier(StringBuilder buf, String... names)
Names in the list may be null, but there must be at least one non-null name in the list.
buf
- Buffernames
- List of names to be quotedpublic String getQuoteIdentifierString()
public void quoteStringLiteral(StringBuilder buf, String s)
For example, in the default dialect,
quoteStringLiteral(buf, "Can't")
appends
"'Can''t'
" to buf
.
public void quoteNumericLiteral(StringBuilder buf, String value)
In the default dialect, numeric literals are printed as is.
public void quoteBooleanLiteral(StringBuilder buf, String value)
In the default dialect, boolean literals are printed as is.
public void quoteDateLiteral(StringBuilder buf, String value)
For example, in the default dialect,
quoteStringLiteral(buf, "1969-03-17")
appends DATE '1969-03-17'
.
public void quoteTimeLiteral(StringBuilder buf, String value)
For example, in the default dialect,
quoteStringLiteral(buf, "12:34:56")
appends TIME '12:34:56'
.
public void quoteTimestampLiteral(StringBuilder buf, String value)
For example, in the default dialect,
quoteStringLiteral(buf, "1969-03-17 12:34:56")
appends TIMESTAMP '1969-03-17 12:34:56'
.
public boolean isFirebird()
public boolean isInformix()
public boolean isIngres()
public boolean isInterbase()
public boolean isLucidDB()
public boolean isMSSQL()
public boolean isOracle()
public boolean isPostgres()
public boolean isMySQL()
public boolean isSybase()
public boolean isTeradata()
public boolean requiresAliasForFromQuery()
allowsFromQuery()
protected boolean allowsAs()
public boolean allowsFromQuery()
SELECT * FROM (SELECT * FROM t) AS x
requiresAliasForFromQuery()
public boolean allowsCompoundCountDistinct()
COUNT(DISTINCT ...) aggregate function, for example
SELECT COUNT(DISTINCT x, y) FROM t
- See Also:
allowsCountDistinct()
,
allowsMultipleCountDistinct()
public boolean allowsCountDistinct()
For example, Access does not allow
select count(distinct x) from t
public boolean allowsMultipleCountDistinct()
In Derby 10.1,
select couunt(distinct x) from t
is OK, but
select couunt(distinct x), count(distinct y) from t
gives "Multiple DISTINCT aggregates are not supported at this time."
public boolean allowsMultipleDistinctSqlMeasures()
public String generateInline(List<String> columnNames, List<String> columnTypes, List<String[]> valueList)
For example, for Oracle, generates
SELECT 1 AS FOO, 'a' AS BAR FROM dual UNION ALL SELECT 2 AS FOO, 'b' AS BAR FROM dual
For ANSI SQL, generates:
VALUES (1, 'a'), (2, 'b')
columnNames
- List of column namescolumnTypes
- List of column types ("String" or "Numeric")valueList
- List of rows values
public void quote(StringBuilder buf, Object value, SqlQuery.Datatype datatype)
public boolean allowsDdl()
CREATE TABLE
and
DROP INDEX
.
Access seems to allow DDL iff the .mdb file is writeable.
DatabaseMetaData.isReadOnly()
public boolean isNullsCollateLast()
public String forceNullsCollateLast(String expr)
isNullsCollateLast()
is true, there's nothing to do.
public boolean supportsGroupByExpressions()
public boolean supportsGroupingSets()
public boolean supportsUnlimitedValueList()
public boolean requiresOrderByAlias()
For example, in such a dialect,
SELECT x FROM t ORDER BY x + y
would be illegal, but
SELECT x, x + y AS z FROM t ORDER BY z
would be legal.
MySQL, DB2 and Ingres are examples of such dialects.
public boolean allowsOrderByAlias()
For example, in such a dialect,
SELECT x, x + y AS z FROM t ORDER BY z
would be legal.
MySQL, DB2 and Ingres are examples of dialects where this is true; Access is a dialect where this is false.
public boolean supportsMultiValueInExpr()
WHERE (col1, col2) IN ((val1a, val2a), (val1b, val2b))
public boolean supportsResultSetConcurrency(int type, int concurrency)
The result is similar to
DatabaseMetaData.supportsResultSetConcurrency(int, int)
,
except that the JdbcOdbc bridge in JDK 1.6 overstates its abilities.
See bug 1690406.
SQLException
- if a database access error occurstype
- defined in ResultSet
concurrency
- type defined in ResultSet
true
if so; false
otherwisepublic String toString()
toString
in class Object
public int getMaxColumnNameLength()
DatabaseMetaData.getMaxColumnNameLength()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |