mondrian.spi.impl
Class AccessDialect

java.lang.Object
  extended by mondrian.spi.impl.JdbcDialectImpl
      extended by mondrian.spi.impl.AccessDialect
All Implemented Interfaces:
Dialect

public class AccessDialect
extends JdbcDialectImpl

Implementation of Dialect for the Microsoft Access database (also called the JET Engine).

Since:
Nov 23, 2008
Version:
$Id: //open/mondrian/src/main/mondrian/spi/impl/AccessDialect.java#4 $
Author:
jhyde

Nested Class Summary
 
Nested classes/interfaces inherited from interface mondrian.spi.Dialect
Dialect.DatabaseProduct, Dialect.Datatype, Dialect.NullCollation
 
Field Summary
static JdbcDialectFactory FACTORY
           
 
Fields inherited from class mondrian.spi.impl.JdbcDialectImpl
databaseProduct, permitsSelectNotInGroupBy, productVersion
 
Constructor Summary
AccessDialect(java.sql.Connection connection)
          Creates an AccessDialect.
 
Method Summary
 boolean allowsCountDistinct()
          Returns whether this Dialect supports distinct aggregations.
 java.lang.String caseWhenElse(java.lang.String cond, java.lang.String thenExpr, java.lang.String elseExpr)
          Generates a conditional statement in this dialect's syntax.
 java.lang.String generateInline(java.util.List<java.lang.String> columnNames, java.util.List<java.lang.String> columnTypes, java.util.List<java.lang.String[]> valueList)
          Generates a SQL statement to represent an inline dataset.
 java.lang.String generateOrderItem(java.lang.String expr, boolean nullable, boolean ascending)
          Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate after all non-NULL values.
 Dialect.NullCollation getNullCollation()
          Returns the rule which determines whether NULL values appear first or last when sorted using ORDER BY.
protected  void quoteDateLiteral(java.lang.StringBuilder buf, java.lang.String value, java.sql.Date date)
          Helper method for JdbcDialectImpl.quoteDateLiteral(StringBuilder, String).
 boolean requiresUnionOrderByExprToBeInSelectClause()
          Returns true if this dialect allows an expression in the ORDER BY clause of a UNION (or other set operation) query only if it occurs in the SELECT clause.
 java.lang.String toUpper(java.lang.String expr)
          Converts an expression to upper case.
 
Methods inherited from class mondrian.spi.impl.JdbcDialectImpl
allowsAs, allowsCompoundCountDistinct, allowsDdl, allowsDialectSharing, allowsFromQuery, allowsMultipleCountDistinct, allowsMultipleDistinctSqlMeasures, allowsOrderByAlias, allowsSelectNotInGroupBy, appendHintsAfterFromClause, deduceIdentifierQuoteString, deduceMaxColumnNameLength, deduceProductName, deduceProductVersion, deduceReadOnly, deduceSupportedResultSetStyles, deduceSupportsSelectNotInGroupBy, generateInlineForAnsi, generateInlineGeneric, getDatabaseProduct, getMaxColumnNameLength, getProduct, getQuoteIdentifierString, needsExponent, quote, quoteBooleanLiteral, quoteDateLiteral, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteNumericLiteral, quoteStringLiteral, quoteTimeLiteral, quoteTimestampLiteral, requiresAliasForFromQuery, requiresGroupByAlias, requiresOrderByAlias, requiresUnionOrderByOrdinal, supportsGroupByExpressions, supportsGroupingSets, supportsMultiValueInExpr, supportsOrderByNullsLast, supportsResultSetConcurrency, supportsUnlimitedValueList, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FACTORY

public static final JdbcDialectFactory FACTORY
Constructor Detail

AccessDialect

public AccessDialect(java.sql.Connection connection)
              throws java.sql.SQLException
Creates an AccessDialect.

Parameters:
connection - Connection
Throws:
java.sql.SQLException
Method Detail

toUpper

public java.lang.String toUpper(java.lang.String expr)
Description copied from interface: Dialect
Converts an expression to upper case.

For example, for MySQL, toUpper("foo.bar") returns "UPPER(foo.bar)".

Specified by:
toUpper in interface Dialect
Overrides:
toUpper in class JdbcDialectImpl
Parameters:
expr - SQL expression
Returns:
SQL syntax that converts expr into upper case.

caseWhenElse

public java.lang.String caseWhenElse(java.lang.String cond,
                                     java.lang.String thenExpr,
                                     java.lang.String elseExpr)
Description copied from interface: Dialect
Generates a conditional statement in this dialect's syntax.

For example, caseWhenElse("b", "1", "0") returns "case when b then 1 else 0 end" on Oracle, "Iif(b, 1, 0)" on Access.

Specified by:
caseWhenElse in interface Dialect
Overrides:
caseWhenElse in class JdbcDialectImpl
Parameters:
cond - Predicate expression
thenExpr - Expression if condition is true
elseExpr - Expression if condition is false
Returns:
Conditional expression

quoteDateLiteral

protected void quoteDateLiteral(java.lang.StringBuilder buf,
                                java.lang.String value,
                                java.sql.Date date)
Description copied from class: JdbcDialectImpl
Helper method for JdbcDialectImpl.quoteDateLiteral(StringBuilder, String).

Overrides:
quoteDateLiteral in class JdbcDialectImpl
Parameters:
buf - Buffer to append to
value - Value as string
date - Value as date

getNullCollation

public Dialect.NullCollation getNullCollation()
Description copied from interface: Dialect
Returns the rule which determines whether NULL values appear first or last when sorted using ORDER BY.

According to the SQL standard, this is implementation-specific. The default behavior is Dialect.NullCollation.POSINF.

Specified by:
getNullCollation in interface Dialect
Overrides:
getNullCollation in class JdbcDialectImpl
Returns:
Rule which determines whether NULL values collate first or last

generateOrderItem

public java.lang.String generateOrderItem(java.lang.String expr,
                                          boolean nullable,
                                          boolean ascending)
Description copied from interface: Dialect
Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate after all non-NULL values.

By default, generateOrderItem(expr, true) generates "expr ASC" and generateOrderItem(expr, false) generates "expr DESC". But depending on Dialect.getNullCollation() and ascending, there may need to be additional code.

For example, on Oracle, where NULLs collate higher than all other values, generateOrderItem(expr, true) generates "expr ASC" and generateOrderItem(expr, false) generates "expr DESC NULLS LAST".

On MySQL, where NULLs collate lower than all other values, generateOrderItem(expr, true) generates "ISNULL(expr), expr ASC" and generateOrderItem(expr, false) generates "expr DESC".

Specified by:
generateOrderItem in interface Dialect
Overrides:
generateOrderItem in class JdbcDialectImpl
Parameters:
expr - Expression
nullable - Whether expression may have NULL values
ascending - Whether to sort expression ascending
Returns:
Expression modified so that NULL values collate last

requiresUnionOrderByExprToBeInSelectClause

public boolean requiresUnionOrderByExprToBeInSelectClause()
Description copied from interface: Dialect
Returns true if this dialect allows an expression in the ORDER BY clause of a UNION (or other set operation) query only if it occurs in the SELECT clause.

For example, SELECT x, y + z FROM t
UNION ALL
SELECT x, y + z FROM t
ORDER BY y + z
is allowed but SELECT x, y, z FROM t
UNION ALL
SELECT x, y, z FROM t
ORDER BY y + z
SELECT x, y, z FROM t ORDER BY y + z is not.

Access is an example of a dialect with this restriction.

Specified by:
requiresUnionOrderByExprToBeInSelectClause in interface Dialect
Overrides:
requiresUnionOrderByExprToBeInSelectClause in class JdbcDialectImpl
Returns:
whether this dialect allows an expression in the ORDER BY clause of a UNION (or other set operation) query only if it occurs in the SELECT clause

allowsCountDistinct

public boolean allowsCountDistinct()
Description copied from interface: Dialect
Returns whether this Dialect supports distinct aggregations.

For example, Access does not allow

select count(distinct x) from t

Specified by:
allowsCountDistinct in interface Dialect
Overrides:
allowsCountDistinct in class JdbcDialectImpl
Returns:
whether Dialect allows COUNT DISTINCT

generateInline

public java.lang.String generateInline(java.util.List<java.lang.String> columnNames,
                                       java.util.List<java.lang.String> columnTypes,
                                       java.util.List<java.lang.String[]> valueList)
Description copied from interface: Dialect
Generates a SQL statement to represent an inline dataset.

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')
 

Specified by:
generateInline in interface Dialect
Overrides:
generateInline in class JdbcDialectImpl
Parameters:
columnNames - List of column names
columnTypes - List of column types ("String" or "Numeric")
valueList - List of rows values
Returns:
SQL string

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads