| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.datatools.modelbase.sql.query.helper.StatementHelper
public class StatementHelper
| Nested Class Summary | |
|---|---|
| static class | StatementHelper.ValueExpressionComparatorComparator for sorting ValueExpressionVariables. | 
| Field Summary | |
|---|---|
| static char | DELIMITED_IDENTIFIER_QUOTETODO: make that DELIMITED_IDENTIFIER_QUOTE char flexible with Database info String constant for the quote that are used for delimited identifiers like "Col1" where this delimited identifier should not be modified to or be compared equal to COL1 or col1, value: "\"", the character " | 
| static int | STATEMENT_TYPE_DELETE | 
| static int | STATEMENT_TYPE_FULLSELECT | 
| static int | STATEMENT_TYPE_INSERT | 
| static int | STATEMENT_TYPE_MERGE | 
| static int | STATEMENT_TYPE_SELECT | 
| static int | STATEMENT_TYPE_UPDATE | 
| static int | STATEMENT_TYPE_WITH | 
| Constructor Summary | |
|---|---|
| StatementHelper() | |
| StatementHelper(Database database) | |
| Method Summary | |
|---|---|
|  void | addNewName(Table selectedTable)Provide the name that will be generated next this is for populating alias text field with a default | 
| static int | compareSQL(java.lang.String sql1,
           java.lang.String sql2)Compares the SQL source of the given SQL fragments according to their syntax. | 
| static int | compareSQL(java.lang.String sql1,
           java.lang.String sql2,
           char identifierDelimiterQt)Compares the SQL source of the given SQL fragments according to their syntax. | 
| static java.lang.String | concatName(java.lang.String name,
           int count)Return a new name concatenating the int (inside delimiters if need be) Assumes that the name is well-formed, ending with a delimiter if it begins with one. | 
| static java.lang.String | convertCatalogIdentifierToSQLFormat(java.lang.String catalogIdentifier,
                                    char idDelimiterQuote)Converts an identifier from catalog format to SQL format. | 
| static java.lang.String | convertSQLIdentifierToCatalogFormat(java.lang.String sqlIdentifier,
                                    char idDelimiterQuote)Converts an identifier from SQL format to catalog format. | 
| static ValueExpressionColumn | createColumnExpression(java.lang.String name)Create a new ValueExpressionColumnwith the given name. | 
| static ColumnName | createColumnName(java.lang.String name)Creates the new ColumnName object and sets the given name. | 
| static QueryDeleteStatement | createDeleteStatement(java.lang.String name) | 
| static QueryInsertStatement | createInsertStatement(java.lang.String name)return false if we cannot find the input name | 
|  QueryInsertStatement | createInsertStatement(java.lang.String name,
                      boolean addToDb)Deprecated. | 
| static QueryMergeStatement | createMergeStatement(java.lang.String name)Creates an empty MERGE statement with the given name. | 
| static QueryCombined | createQueryCombined()Creates a QueryCombined | 
| static QuerySelectStatement | createQueryCombinedStatement(java.lang.String name)Creates a QuerySelectStatement statement, with a QueryCombined in it | 
| static QueryExpressionRoot | createQueryExpressionRoot()Creates a QueryExpressionRoot | 
| static QueryExpressionRoot | createQueryExpressionRoot(QuerySelectStatement aParent)Creates a QueryExpressionRoot and attaches it to QuerySelectStatement | 
| static QueryNested | createQueryNested()Creates a QueryNested object. | 
| static QuerySelect | createQuerySelect()Creates a QuerySelect Object | 
| static QuerySelect | createQuerySelect(QueryExpressionRoot anExpRoot)Creates a QuerySelect Object and hook it to a QueryExpressionRoot | 
| static QuerySelect | createQuerySelect(QuerySelectStatement aStatement)Creates a QuerySelect Object and hook it to a QuerySelectStatement | 
| static QuerySelectStatement | createQuerySelectStatement(java.lang.String aName)Creates a QuerySelectStatement | 
| static QueryStatement | createQueryStatement(int stmtType,
                     java.lang.String stmtName)Creates a statement of the given type with the given name. | 
|  QuerySelectStatement | createSelectStatement(java.lang.String name) | 
| static QueryUpdateStatement | createUpdateStatement(java.lang.String name) | 
|  QueryUpdateStatement | createUpdateStatement(java.lang.String name,
                      boolean addToDb)Deprecated. | 
| static QuerySelectStatement | createWithStatement(java.lang.String name)Creates a WITH query statement. | 
| static WithTableReference | createWithTableReferenceForWithTable(WithTableSpecification withTableSpec)Creates a new WithTableReferencefor the givenwithTableSpecand createsValueExpressionColumnobjects for each of the givenWithTableSpecification's declared columns (WithTableSpecification.getColumnNameList())
 or, if columns are not declared, for each of theWithTableSpecification's query's result columns. | 
| static boolean | equalSQLIdentifiers(java.lang.String ident1,
                    java.lang.String ident2)Determines whether two SQL identifiers are equal, respecting delimited identifiers using the default delimited identifier quote character. | 
| static boolean | equalSQLIdentifiers(java.lang.String ident1,
                    java.lang.String ident2,
                    char delimiterChar)Determines whether two SQL identifiers are equal, respecting delimited identifiers using the given quote character as delimiter. | 
| static ResultColumn | findResultColumnForColumnExpression(QuerySelect select,
                                    ValueExpressionColumn columnExpr)Returns nullor theResultColumnof the
 givenQuerySelectwhoseValueExpressionis
 of typeValueExpressionColumnwhich innameandtableExprequals the givencolumnExpr. | 
| static ResultColumn | findResultColumnForColumnNameOrAlias(QuerySelect select,
                                     java.lang.String columnNameOrAlias)Returns nullor theResultColumnof the
 givenQuerySelectwhosenamematches the
 givencolumnNameOrAliasor whoseValueExpressionis of typeValueExpressionColumnwhich has anamematching the givencolumnNameOrAlias. | 
| static java.util.List | getAllParameterMarkersInQueryStatement(QueryStatement queryStmt)Gets all the parameter marker-type ("?") variables in the given query statement. | 
| static java.util.List | getAllVariablesInQueryStatement(QueryStatement queryStmt)Returns all ValueExpressionVariablescontained in the
 givenQueryStatement. | 
| static java.util.List | getAllVariablesInQueryStatement(QueryStatement queryStmt,
                                boolean nameParameterMarkers)Returns all ValueExpressionVariablescontained in the
 givenQueryStatement. | 
| static java.util.List | getAllVariablesInQueryStatement(QueryStatement queryStmt,
                                boolean nameParameterMarkers,
                                java.lang.String varStem)Returns all ValueExpressionVariablescontained in the
 givenQueryStatement. | 
| static java.util.List | getAllVariablesInQueryStatement(QueryStatement queryStmt,
                                java.lang.String varStem)Returns all ValueExpressionVariablescontained in the
 givenQueryStatement. | 
| static Database | getDatabase(QueryStatement stmt)Returns the Database for which SQL Statement is associated with. | 
| static char | getDELIMITED_IDENTIFIER_QUOTE()Gets the DELIMITED_IDENTIFIER_QUOTE char. | 
| static TableInDatabase | getDerivedDatabaseTable(ValueExpressionColumn columnExpr)Returns the TableInDatabasethat the givencolumnExprwas derived from, if the given column is not
 the result of an expression in theselectClauseof aQuerySelector the result column of aQueryValues. | 
| static java.util.List | getDerivedDatabaseTables(java.util.List columnExprList)Returns the TableInDatabases, that the givencolumnExprs were derived from, if the given columns are
 not the result of an expression in theselectClauseof aQuerySelector the result column of aQueryValues. | 
| static java.util.Set | getDirectReferences(org.eclipse.emf.ecore.EObject eObject,
                    java.lang.Class typeFilter)Returns all directly referenced Objects of the given eObjectthat are of type or a subtype of the giventypeFilter. | 
| static SQLQueryObject | getEContainerRecursively(org.eclipse.emf.ecore.EObject eObject,
                         java.lang.Class containerType)Returns the EObject.eContainer()for the giveneObjectthat is assignable to the given typecontainerType. | 
| static java.util.List | getEffectiveResultColumns(QuerySelectStatement selectStmt)This method compiles a list of ValueExpressionColumns
 that reflects the columns, in order and with datatype, which are the
 result of the givenQuerySelectStatement. | 
| static QuerySearchCondition | getHavingCondition(QueryStatement stmt)Returns "Having" clause for the given statement. | 
| static QuerySearchCondition | getHavingCondition(SQLQueryObject stmt) | 
| static java.util.List | getMergeModificationTargetColumnReferences(QueryMergeStatement mergeStmt)Gets a list of the column value expression in the "modification operations" (Update/Insert) of the given Merge statement that are known to be references to columns in the target table of the Merge statement. | 
|  java.lang.String | getNewName(QueryInsertStatement insert) | 
| static Predicate | getPredicateOfVariable(ValueExpressionVariable variable)Returns the Predicateof the givenvariableornull, if thevariablehas no reference
 to aPredicate. | 
| static QuerySelect | getQuerySelectForTableReference(TableExpression tableExpr)Returns the QuerySelectthat contains the giventableExprin itsfromClause. | 
| static QueryStatement | getQueryStatementForTableReference(TableReference tableRef)Returns the QueryStatementassociated with the giventableRef. | 
| static java.util.Set | getReferencesRecursively(org.eclipse.emf.ecore.EObject eObject,
                         java.lang.Class typeFilter)Returns all Objects recursively referenced by the given eObject, that are of type or a subtype of the giventypeFilter. | 
| static java.util.Set | getReferencesViaSpecificReferencePaths(org.eclipse.emf.ecore.EObject eObject,
                                       java.lang.Class typeFilter,
                                       java.lang.Class[] referencePathTypes)Returns Objects recursively referenced by the given eObject,
 that are of type or a subtype of the giventypeFilter. | 
| static java.util.List | getResultTableAllColumnsInQueryResultSpecificationList(java.util.List queryResultSpecList)Returns a List containing only the QueryResultSpecifications
 in the givenqueryResultSpecListthat are of typeResultTableAllColumns. | 
| static QuerySearchCondition | getSearchCondition(QueryStatement stmt)Returns QuerySearchCondition for the given statement. | 
| static QuerySearchCondition | getSearchCondition(SQLQueryObject stmt) | 
| static java.lang.String | getSQLForExecution(SQLQueryObject queryObject)Generates SQL source for the given queryObjectwithout any
 comments and with the current schema qualified tables. | 
| static java.lang.String | getSQLQualified(SQLQueryObject queryObject,
                int qualificationSpec)Returns the SQL source text of the given SQLQueryObjectwith all identifiers (table and column references) qualified according to
 the givenqualificationSpec. | 
| static java.lang.String | getSQLSchemaQualified(SQLQueryObject queryObject)Returns the SQL source text of the given SQLQueryObjectwith all identifiers (table and column references) qualified with their
 schema name. | 
| static java.lang.String | getSQLSourceUnformatted(SQLQueryObject queryObject)Returns the generated SQL source for the given queryObjectwithout any formatting and without comments in a single line. | 
| static java.lang.String | getSQLSourceUnformatted(java.lang.String queryStmt)Returns the given SQL source String in a single line without any formatting. | 
| static java.lang.String | getSQLTableQualified(SQLQueryObject queryObject)Returns the SQL source text of the given SQLQueryObjectwith all column references qualified with table names, but all table
 names unqualified (without schema name). | 
| static java.lang.String | getSQLUnqualified(SQLQueryObject queryObject)Returns the SQL source text of the given SQLQueryObjectwith all identifiers unqualified (column references without table names,
 and all table references without schema names). | 
| static java.lang.String | getSQLWithComments(SQLQueryObject queryObject)Returns the generated SQL source for the given queryObjectwith all comments. | 
| static java.lang.String | getSQLWithoutComments(SQLQueryObject queryObject)Returns the generated SQL source for the given queryObjectwithout any comments. | 
| static int | getStatementType(QueryStatement statement)Returns the integer constant defined in this class, that represents the given QueryStatement | 
| static TableExpression | getTableExpressionForTable(Table table,
                           QuerySelect qSelect)Returns the TableExpression representing the given Table object,in the given QuerySelect | 
| static TableExpression | getTableExpressionForTable(Table table,
                           QuerySelectStatement selectStmt)Returns the TableExpression representing the given Table object,in the given QuerySelectStatement | 
| static java.util.List | getTableExpressionsInQueryExpressionBody(QueryExpressionBody query) | 
| static java.util.List | getTableExpressionsInQuerySelect(QuerySelect querySelect) | 
| static java.util.List | getTableExpressionsVisibleInQuerySelect(QuerySelect querySelect)Returns the TableExpressions in the givenQuerySelect'sfromClauseplus all theTableExpressions that are visible in the scope of the
 givenQuerySelect. | 
| static java.util.List | getTablesForStatement(QueryStatement stmt)Returns List of tables ( TableExpression) referenced in
 the statement. | 
| static java.util.List | getTablesForStatement(SQLQueryObject stmt) | 
| static java.lang.String | getTemplateSQL(int statementType)Returns the default SQL template for a statement | 
| static java.lang.String | getUniqueVarName(java.util.Vector varNames,
                 java.lang.String name)Return a unique name for adding an attribute by appending a count to the passed string and also checking for the existence of the name in the vector. | 
| static boolean | isColumnNameAmbiguous(ValueExpressionColumn colExpr)Returns true only if the name of the given column expression is equal to another column's name in a different table. | 
| static boolean | isNameUnique(java.util.Vector names,
             java.lang.String uniqueName)Checks the passed uniqueName is in the passed array names and returns false if found, true otherwise. | 
| static boolean | isOrderByClauseContainsValidOrderBySpecification(java.util.List orderByClause)Returns true, if at least oneOrderBySpecificationcontained in the givenorderByClauselist is valid. | 
| static boolean | isOrderBySpecificationValid(OrderBySpecification orderBySpec) | 
| static boolean | isTableNameAmbiguous(TableExpression tableExpr)Returns trueif the giventableExpr'snameis not unique within thefromClauseof
 its containingQuerySelectand the otherTableExpressions in thefromClauseas well
 as the givenTableExpressionhave noTableCorrelationto distinguish between them. | 
| static boolean | isTemplateSQL(java.lang.String sql)Checks to see if the given string is same as the template for any of the DML statements | 
| static void | logDebug(java.lang.String debugMsg) | 
| static void | logError(java.lang.String errorMsg) | 
| static boolean | omitSchema(TableInDatabase tableInDB)Returns trueif the giventableInDBdoes
 not have to be qualified with itsSchemaname. | 
| static java.lang.String | removeCommentsInSQL(java.lang.String statement,
                    char delimitedIdentifierQt)Walks through the given SQL and strips out the comments that are identified by two dashes in line "--" and that are not part of a delimited character string (single quotes), or SQL delimited object name (double quotes). | 
| static void | removeTableExpressionFromQueryStatement(TableExpression tableExpr,
                                        SQLQueryObject queryObj)Removes the given TableExpressionfrom the givenSQLQueryObject. | 
| static void | removeValueExpression(QueryValueExpression valExpr)Removes the given ValueExpression object from the object that contains it. | 
| static java.util.Set | resolveOrderByColumns(QueryExpressionBody queryExpr,
                      java.util.List orderByList) | 
| static java.util.Set | resolveOrderByColumns(QuerySelect select,
                      java.util.List orderBySpecList)Every given OrderBySpecifications contained in the givenorderByList, that is of typeOrderByValueExpressionand its ownedValueExpressionis of typeValueExpressionColumn, will be removed from the givenQuerySelectand substituted by a newOrderByResultColumnthat will then be given the reference
 to theValueExpressionColumnformerly associated to the
 removedOrderByValueExpression, if the givenQuerySelecthas aResultColumnthat refers
 by itsnameto the sameValueExpressionColumn. | 
| static void | resolveQueryResultSpecification(QuerySelect querySelect)Resolves columnExpressions and tableReferences in given querySelect'sQueryResultSpecificationResultColumnorResultTableAllColumnswith the columnExpressions and
 tableExpressions in the givenquerySelect'sfromClause. | 
| static void | resolveResultTableAllColumns(QuerySelect querySelect)Resolves tableReferences in given querySelect'sQueryResultSpecifications of typeResultTableAllColumnswith the tableExpressions in the
 givenquerySelect'sfromClause. | 
| static WithTableReference | resolveWithTableSpecificationReference(TableExpression potentialWithTableRef)Substitutes the given TableReferencewith theWithTableSpecificationthat is refered by the givenpotentialTableWithRef'sname, if aTableWithSpecificationis found in theQueryExpressionRootthat contains the givenTableReference. | 
| static void | setDELIMITED_IDENTIFIER_QUOTE(char delimited_identifier_quote)Sets the DELIMITED_IDENTIFIER_QUOTE char to make this class flexible with Database info String constant for the quote that are used for delimited identifiers like "Col1" where this delimited identifier should not be modified to or be compared equal to COL1 or col1, value: "\"", the character " | 
| static void | setHavingClauseForStatement(QuerySearchCondition newSearchCon,
                            QueryStatement statement)Sets the having clause in the given sql statement. | 
| static void | setHavingClauseForStatement(QuerySearchCondition newSearchCon,
                            SQLQueryObject statement)Sets the having clause in the given SQLQueryObject. | 
| static void | setWhereClauseForStatement(QuerySearchCondition newSearchCon,
                           QueryStatement statement)Sets the where clause in the given sql statement. | 
| static void | setWhereClauseForStatement(QuerySearchCondition newSearchCon,
                           SQLQueryObject statement)Sets the where clause in the given sqlQueryObject. | 
| static java.lang.String | stripWhiteSpace(java.lang.String sql,
                char delimitedIdentifierQt)Strips of the optional whitespace from the given sqland
 replaces all new lines with single spaces. | 
| Methods inherited from class java.lang.Object | 
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static char DELIMITED_IDENTIFIER_QUOTE
public static final int STATEMENT_TYPE_DELETE
public static final int STATEMENT_TYPE_FULLSELECT
public static final int STATEMENT_TYPE_INSERT
public static final int STATEMENT_TYPE_SELECT
public static final int STATEMENT_TYPE_UPDATE
public static final int STATEMENT_TYPE_WITH
public static final int STATEMENT_TYPE_MERGE
| Constructor Detail | 
|---|
public StatementHelper()
public StatementHelper(Database database)
| Method Detail | 
|---|
public static char getDELIMITED_IDENTIFIER_QUOTE()
public static void setDELIMITED_IDENTIFIER_QUOTE(char delimited_identifier_quote)
public static int compareSQL(java.lang.String sql1,
                             java.lang.String sql2)
sql1 - sql2 - 
0 if the given SQL fragments are syntactically
         equivalent
public static int compareSQL(java.lang.String sql1,
                             java.lang.String sql2,
                             char identifierDelimiterQt)
sql1 - sql2 - identifierDelimiterQt - 
0 if the given SQL fragments are syntactically
         equivalent
public static java.lang.String convertCatalogIdentifierToSQLFormat(java.lang.String catalogIdentifier,
                                                                   char idDelimiterQuote)
| SQL format | Catalog format | 
|---|---|
| schema1 Schema1 SCHEMA1 "SCHEMA1" | SCHEMA1 | 
| "Schema1" | Schema1 | 
| "Sch""ma1" | Sch"ma1 | 
| "Table A" | Table A | 
| Table A | Error | 
| Sch"ma1 | Error | 
catalogIdentifier - identifier in catalog formatidDelimiterQuote - 
public static java.lang.String convertSQLIdentifierToCatalogFormat(java.lang.String sqlIdentifier,
                                                                   char idDelimiterQuote)
| SQL format | Catalog format | 
|---|---|
| schema1 Schema1 SCHEMA1 "SCHEMA1" | SCHEMA1 | 
| "Schema1" | Schema1 | 
| "Sch""ma1" | Sch"ma1 | 
| "Table A" | Table A | 
| Table A | Error | 
| Sch"ma1 | Error | 
sqlIdentifier - identifier in SQL formatidDelimiterQuote - 
public static ValueExpressionColumn createColumnExpression(java.lang.String name)
ValueExpressionColumn with the given name.
name - optional name of the result column
public static ColumnName createColumnName(java.lang.String name)
name - the String name of the ColumnName.
public static QueryDeleteStatement createDeleteStatement(java.lang.String name)
public static QueryInsertStatement createInsertStatement(java.lang.String name)
public static QueryMergeStatement createMergeStatement(java.lang.String name)
name - the name for the statement
public static QueryCombined createQueryCombined()
public static QuerySelectStatement createQueryCombinedStatement(java.lang.String name)
name - the name of the statement.
public static QueryExpressionRoot createQueryExpressionRoot()
public static QueryExpressionRoot createQueryExpressionRoot(QuerySelectStatement aParent)
aParent - the parent QuerySelectStatement
public static QueryNested createQueryNested()
public static QuerySelect createQuerySelect()
public static QuerySelect createQuerySelect(QueryExpressionRoot anExpRoot)
anExpRoot - the QueryExpressionRoot
public static QuerySelect createQuerySelect(QuerySelectStatement aStatement)
aStatement - the QuerySelectStatement
public static QuerySelectStatement createQuerySelectStatement(java.lang.String aName)
aName - the name of the statement
public static QueryStatement createQueryStatement(int stmtType,
                                                  java.lang.String stmtName)
stmtType - the requested statement typestmtName - the name for the statement
public static QueryUpdateStatement createUpdateStatement(java.lang.String name)
public static QuerySelectStatement createWithStatement(java.lang.String name)
name - the String name of the statement.
public static WithTableReference createWithTableReferenceForWithTable(WithTableSpecification withTableSpec)
WithTableReference for the given
 withTableSpec and creates
 ValueExpressionColumn objects for each of the given
 WithTableSpecification's declared columns (WithTableSpecification.getColumnNameList())
 or, if columns are not declared, for each of the
 WithTableSpecification's query's result columns.
withTableSpec - 
public static boolean equalSQLIdentifiers(java.lang.String ident1,
                                          java.lang.String ident2)
ident1 - a SQL identifierident2 - another SQL identifier
public static boolean equalSQLIdentifiers(java.lang.String ident1,
                                          java.lang.String ident2,
                                          char delimiterChar)
ident1 - a SQL identifierident2 - another SQL identifieridentDelimiterQuote - the delimiter char
public static ResultColumn findResultColumnForColumnExpression(QuerySelect select,
                                                               ValueExpressionColumn columnExpr)
null or the ResultColumn of the
 given QuerySelect whose ValueExpression is
 of type ValueExpressionColumn which in name
 and tableExpr equals the given columnExpr.
select - columnExpr - a ValueExpressionColumn
public static ResultColumn findResultColumnForColumnNameOrAlias(QuerySelect select,
                                                                java.lang.String columnNameOrAlias)
null or the ResultColumn of the
 given QuerySelect whose name matches the
 given columnNameOrAlias or whose
 ValueExpression is of type
 ValueExpressionColumn which has a name
 matching the given columnNameOrAlias.
select - columnNameOrAlias - 
public static java.util.List getAllParameterMarkersInQueryStatement(QueryStatement queryStmt)
queryStmt - 
public static java.util.List getAllVariablesInQueryStatement(QueryStatement queryStmt)
ValueExpressionVariables contained in the
 given QueryStatement.  All parameter marker-type ("?")
 variables will be modified to have names VAR0n where n is a sequence
 number.
queryStmt - the statement from which variables are wanted
ValueExpressionVariable
public static java.util.List getAllVariablesInQueryStatement(QueryStatement queryStmt,
                                                             java.lang.String varStem)
ValueExpressionVariables contained in the
 given QueryStatement.
queryStmt - A SQL statement that might have host variables or parameter markersvarStem - The stem for naming variables from parameter markers
ValueExpressionVariable
public static java.util.List getAllVariablesInQueryStatement(QueryStatement queryStmt,
                                                             boolean nameParameterMarkers)
ValueExpressionVariables contained in the
 given QueryStatement.
queryStmt - A SQL statement that might have host variables or parameter markersnameParameterMarkers - True if you wish to generate names for parameter markers
ValueExpressionVariable
public static java.util.List getAllVariablesInQueryStatement(QueryStatement queryStmt,
                                                             boolean nameParameterMarkers,
                                                             java.lang.String varStem)
ValueExpressionVariables contained in the
 given QueryStatement.
queryStmt - A SQL statement that might have host variables or parameter markersnameParameterMarkers - True if you wish to generate names for parameter markersvarStem - The stem for naming variables from parameter markers
ValueExpressionVariable
public static java.lang.String getUniqueVarName(java.util.Vector varNames,
                                                java.lang.String name)
attrNames - All attribute names in the type including the
        inherited attribute names.name - Name that we append count to.
public static boolean isNameUnique(java.util.Vector names,
                                   java.lang.String uniqueName)
names - Array of namesuniqueName - The name to be checked.
public static java.lang.String concatName(java.lang.String name,
                                          int count)
public static Database getDatabase(QueryStatement stmt)
stmt - the SQLQueryStatement for which Database is needed
public static TableInDatabase getDerivedDatabaseTable(ValueExpressionColumn columnExpr)
TableInDatabase that the given
 columnExpr was derived from, if the given column is not
 the result of an expression in the selectClause of a
 QuerySelect or the result column of a
 QueryValues. The derived table of "c1" in "select t1.col1
 as c1 from (select col1 from table1) as t1;" would be "table1".
columnExpr - a ValueExpressionColumn that is part of
        a TableExpression s columnList(
        TableExpression.getColumnList()) as the tables exposed
        ordered result columns (not the ResultColumn of a
        QuerySelect)
TableInDatabase the given column was derived
         from or null if the given column is not derived
         from a TableInDatabasepublic static java.util.List getDerivedDatabaseTables(java.util.List columnExprList)
TableInDatabases, that the given
 columnExprs were derived from, if the given columns are
 not the result of an expression in the selectClause of a
 QuerySelect or the result column of a
 QueryValues. The derived tables of "select t1.col1,
 t2.col1 from table1 t1, table2 t2" would be "table1" and "table2".
columnExprList - a List of ValueExpressionColumns
        that are part of a TableExpression s
        columnList(
        TableExpression.getColumnList()), the tables exposed
        ordered result columns (not the ResultColumn of a
        QuerySelect!)
TableInDatabases that the given
         columns were derived from, can be empty
public static java.util.Set getDirectReferences(org.eclipse.emf.ecore.EObject eObject,
                                                java.lang.Class typeFilter)
eObject
 that are of type or a subtype of the given typeFilter.
eObject - the EObject we want to find refernces fortypeFilter - optional the type of the refernced Objects to be
        returned, may be null or Object.class
        to not filter the refernces
public static SQLQueryObject getEContainerRecursively(org.eclipse.emf.ecore.EObject eObject,
                                                      java.lang.Class containerType)
EObject.eContainer()for the given
 eObject that is assignable to the given type
 containerType.
 
 For the ValueExpressionColumn "col1" in the
 QuerySelect that represents the query
 SELECT * FROM tbl1 WHERE col1 = 1, the eConatiner would
 be a PredicateBasic "col1 = 1", but the eConatiner of type
 QuerySelect would be the whole QuerySelect,
 that eContains the PredicateBasic.
eObject - containerType - 
SQLQueryObject of type containerType
         that ultimately contains the given eObjectpublic static java.util.List getEffectiveResultColumns(QuerySelectStatement selectStmt)
ValueExpressionColumns
 that reflects the columns, in order and with datatype, which are the
 result of the given QuerySelectStatement.
 
 Note: this method will not return the ResultColumn
 list of the given selectStmt's QuerySelect,
 because these don't necessarily reflect the effective result columns of a
 star-query for example.
 
 Note: the returned ValueExpressionColumn's
 name can be null, for example when the
 given QuerySelectStatement's query is of type
 QueryValues ("VALUES (1,2),(3,4)") or if the query is a
 QuerySelect with a unnamed ResultColumn
 like in "SELECT COL1 + 10 FROM TABLE1" where "COL1 + 1" has no alias
 name.
selectStmt - 
ValueExpressionColumnspublic static QuerySearchCondition getHavingCondition(QueryStatement stmt)
stmt - the QueryStatement for which Having clause needs to be
        returned
public static QuerySearchCondition getHavingCondition(SQLQueryObject stmt)
public static java.util.List getMergeModificationTargetColumnReferences(QueryMergeStatement mergeStmt)
mergeStmt - the Merge statement for which the modification target columns are needed
ValueExpressionColumn objectspublic static Predicate getPredicateOfVariable(ValueExpressionVariable variable)
Predicate of the given variable
 or null, if the variable has no reference
 to a Predicate.
 
 Note: If more than one reference of type Predicate
 is found for the given variable, the first one found will
 be returned arbitrarily.
 
variable - 
Predicate referencing the given
         ValueExpressionVariablepublic static QuerySelect getQuerySelectForTableReference(TableExpression tableExpr)
QuerySelect that contains the given
 tableExpr in its fromClause.
tableExpr - 
QuerySelectpublic static QueryStatement getQueryStatementForTableReference(TableReference tableRef)
QueryStatement associated with the given
 tableRef.
tableRef - 
public static java.util.Set getReferencesRecursively(org.eclipse.emf.ecore.EObject eObject,
                                                     java.lang.Class typeFilter)
eObject, that are of type or a subtype of the given
 typeFilter.
eObject - the object we want to find refernces oftypeFilter - optional the type of the refernced Objects to be
        returned, may be null or Object.class
        to not filter the refernces
EObject s referenced recursively of type
         assignable to typeFilter
public static java.util.Set getReferencesViaSpecificReferencePaths(org.eclipse.emf.ecore.EObject eObject,
                                                                   java.lang.Class typeFilter,
                                                                   java.lang.Class[] referencePathTypes)
eObject,
 that are of type or a subtype of the given typeFilter.
 Only such references will be traversed that are of one of the give types
 in referencePathTypes.
eObject - the object we want to find refernces oftypeFilter - optional the type of the refernced Objects to be
        returned, may be null or Object.class
        to not filter the referncesreferencePathTypes - the types of references that are traversed to
        reach Objects indirectly referenced by the given
        eObject
EObjects referenced recursivelypublic static java.util.List getResultTableAllColumnsInQueryResultSpecificationList(java.util.List queryResultSpecList)
QueryResultSpecifications
 in the given queryResultSpecList that are of type
 ResultTableAllColumns.
queryResultSpecList - a List of QueryResultSpecification
ResultTableAllColumnspublic static QuerySearchCondition getSearchCondition(QueryStatement stmt)
stmt - the QueryStatement for which search condition needs to be
        returned
public static QuerySearchCondition getSearchCondition(SQLQueryObject stmt)
public static java.lang.String getSQLForExecution(SQLQueryObject queryObject)
queryObject without any
 comments and with the current schema qualified tables.
 
 Note:  this method is not Thread -safe, concurrent
 calls to SQLQueryObject.getSQL() on the given
 queryObject might not return the expected result.
queryObject - a SQLQueryObject to get the SQL source
        for
queryObject
         without any comments and qualified tables
public static java.lang.String getSQLQualified(SQLQueryObject queryObject,
                                               int qualificationSpec)
SQLQueryObject
 with all identifiers (table and column references) qualified according to
 the given qualificationSpec.
 
 
 Note:  this method is not Thread -safe, concurrent
 calls to SQLQueryObject.getSQL() on the given
 queryObject might not return the expected or even a
 semantically invalid result.
queryObject - qualificationSpec - SQLQuerySourceFormat.QUALIFY_IDENTIFIERS_WITH_SCHEMA_NAMES
        SQLQuerySourceFormat.QUALIFY_IDENTIFIERS_WITH_TABLE_NAMES
        SQLQuerySourceFormat.QUALIFY_IDENTIFIERS_NEVER
        SQLQuerySourceFormat.QUALIFY_IDENTIFIERS_IN_CONTEXT
        SQLQueryObjectpublic static java.lang.String getSQLSchemaQualified(SQLQueryObject queryObject)
SQLQueryObject
 with all identifiers (table and column references) qualified with their
 schema name.
 
 Note:  this method is not Thread -safe, concurrent
 calls to SQLQueryObject.getSQL() on the given
 queryObject might not return the expected result.
queryObject - 
SQLQueryObjectpublic static java.lang.String getSQLSourceUnformatted(SQLQueryObject queryObject)
queryObject
 without any formatting and without comments in a single line. The
 returned String will have no occurrence of more than one blank " " or and
 no occurrence of a line break "\n", so that for any given
 SQLQueryObject queryObject
 getSQLSourceUnformatted(queryObject).indexOf(" "+" ") < 0
 is true and
 getSQLSourceUnformatted(queryObject).indexOf("\n") < 0
 is true.
queryObject - a SQLQueryObject to get the SQL source
        for
queryObject
         without any formattingpublic static java.lang.String getSQLSourceUnformatted(java.lang.String queryStmt)
QueryStatement queryStmt
 getSQLSourceUnformatted(queryStmt).indexOf(" "+" ") < 0
 is true and
 getSQLSourceUnformatted(queryStmt).indexOf("\n") < 0 is
 true.
 
 Note: this method only works on SQL statements without
 single-line comments! Use
 stripWhiteSpaceAndComments(String, char) for SQL that contains
 comments.
queryStmt - the SQL source String of a QueryStatement
queryStmt SQL source without any
         formattingpublic static java.lang.String getSQLTableQualified(SQLQueryObject queryObject)
SQLQueryObject
 with all column references qualified with table names, but all table
 names unqualified (without schema name).
 
 Note:  this method is not Thread -safe, concurrent
 calls to SQLQueryObject.getSQL() on the given
 queryObject might not return the expected or even a
 semantically invalid result.
queryObject - 
SQLQueryObjectpublic static java.lang.String getSQLUnqualified(SQLQueryObject queryObject)
SQLQueryObject
 with all identifiers unqualified (column references without table names,
 and all table references without schema names).
 
 Note:  this method is not Thread -safe, concurrent
 calls to SQLQueryObject.getSQL() on the given
 queryObject might not return the expected or even a
 semantically invalid result.
queryObject - 
SQLQueryObjectpublic static java.lang.String getSQLWithComments(SQLQueryObject queryObject)
queryObject
 with all comments.
queryObject - a SQLQueryObject to get the SQL source
        for
queryObject
         with all commentspublic static java.lang.String getSQLWithoutComments(SQLQueryObject queryObject)
queryObject
 without any comments.
queryObject - a SQLQueryObject to get the SQL source
        for
queryObject
         without any commentspublic static int getStatementType(QueryStatement statement)
statement - the QueryStatement
public static TableExpression getTableExpressionForTable(Table table,
                                                         QuerySelect qSelect)
table - the Table objectqSelect - the QuerySelect in which the TableExpression is searched
        for
public static TableExpression getTableExpressionForTable(Table table,
                                                         QuerySelectStatement selectStmt)
table - the Table objectselectStmt - the QuerySelectStatement in which the TableExpression
        is searched for
public static java.util.List getTableExpressionsInQueryExpressionBody(QueryExpressionBody query)
query - 
public static java.util.List getTableExpressionsInQuerySelect(QuerySelect querySelect)
public static java.util.List getTableExpressionsVisibleInQuerySelect(QuerySelect querySelect)
TableExpressions in the given
 QuerySelect's fromClause plus all the
 TableExpressions that are visible in the scope of the
 given QuerySelect.  If the QuerySelect
 given is a nested query or sub-query, all the TableExpressions 
 of the super query are appended to the returned list of
 TableExpressions.
querySelect - the QuerySelect for which the visible table expressions
 are needed
TableExpressionspublic static java.util.List getTablesForStatement(QueryStatement stmt)
TableExpression) referenced in
 the statement. For Select statement it returns the source tables of the
 "From" clause. For Insert, Update and Delete returns the target table.
 For Merge it returns the target (INTO) table and the source (USING) table.
stmt - the SQLQueryStatement from which the table are wanted
public static java.util.List getTablesForStatement(SQLQueryObject stmt)
public static java.lang.String getTemplateSQL(int statementType)
statementType - the type of the statement
public static boolean isColumnNameAmbiguous(ValueExpressionColumn colExpr)
colExpr - the column expression to check
public static boolean isOrderByClauseContainsValidOrderBySpecification(java.util.List orderByClause)
true, if at least one
 OrderBySpecification contained in the given
 orderByClause list is valid.
public static boolean isOrderBySpecificationValid(OrderBySpecification orderBySpec)
orderBySpec - 
public static boolean isTableNameAmbiguous(TableExpression tableExpr)
true if the given tableExpr's
 name is not unique within the fromClause of
 its containing QuerySelect and the other
 TableExpression s in the fromClause as well
 as the given TableExpression have no
 TableCorrelation to distinguish between them. That is
 important for column references to that table, which will have to get
 qualified with the table's Schema name.
tableExpr - 
true if the given tableExpr's
         name is not unique within the
         fromClause of its containing
         QuerySelect and the other
         TableExpression s in the fromClause
         as well as the given TableExpression have no
         TableCorrelation to distinguish between thempublic static boolean isTemplateSQL(java.lang.String sql)
sql - the string to check if it is the template statement
public static void logDebug(java.lang.String debugMsg)
public static void logError(java.lang.String errorMsg)
public static boolean omitSchema(TableInDatabase tableInDB)
true if the given tableInDB does
 not have to be qualified with its Schema name.
 Note: Assumptions:
tableInDB is not null
 tableInDB has (indirect) reference to its
 QueryStatement
 QueryStatement has reference to its
 SQLQuerySourceInfo and that way indirectly a reference to
 a SQLQuerySourceFormat (com.ibm.db.models.sql.query.util.SQLQuerySourceFormat#getOmitSchema())
 
tableInDB - 
true if table name does not have to be qualified
public static java.lang.String removeCommentsInSQL(java.lang.String statement,
                                                   char delimitedIdentifierQt)
 SELECT EMP_NUM FROM DEPARTEMENT -- pre-accumulated number of employees
 
 WHERE LOCATION = 'C-Tower--01' OR LOCATION = 'C-Tower-02'
 
In this statement the first occurence of "--" would indicate a comment that would be stripped of and the second occurence would be retained, as it is part of a String delimited by the enclosing single quotes.
statement - A SQL statementdelimitedIdentifierQt - the quote char used to prefix and suffix
        non-standard identifiers or identifiers that are case sensitive
public static void removeTableExpressionFromQueryStatement(TableExpression tableExpr,
                                                           SQLQueryObject queryObj)
TableExpression from the given SQLQueryObject.
 The SQLQueryObject should be either a QueryStatement or a QuerySelect.
 All references to columns of the TableExpression are removed as well.
tableExpr - the table expression to removequeryObj - the query object from which the table expression should
 be removedpublic static void removeValueExpression(QueryValueExpression valExpr)
valExpr - the object to remove
public static java.util.Set resolveOrderByColumns(QueryExpressionBody queryExpr,
                                                  java.util.List orderByList)
resolveOrderByColumns(QuerySelect, List)
public static java.util.Set resolveOrderByColumns(QuerySelect select,
                                                  java.util.List orderBySpecList)
OrderBySpecifications contained in the given
 orderByList, that is of type
 OrderByValueExpression and its owned
 ValueExpression is of type
 ValueExpressionColumn, will be removed from the given
 QuerySelect and substituted by a new
 OrderByResultColumn that will then be given the reference
 to the ValueExpressionColumn formerly associated to the
 removed OrderByValueExpression, if the given
 QuerySelect has a ResultColumn that refers
 by its name to the same ValueExpressionColumn.
 In other words, the type of a OrderByValueExpression,
 that references a ValueExpressionColumn also referred to
 by one ResultColumn of the given select,
 will be changed to OrderByResultColumn.
 
 Note: Returns the Set of ValueExpressionColumns
 that have been removed from their OrderByValueExpression.
 
select - orderBySpecList - List of OrderBySpecifications
        referring to the given QuerySelect
ValueExpressionColumns that have been
         removed from their OrderByValueExpressionpublic static void resolveQueryResultSpecification(QuerySelect querySelect)
querySelect's QueryResultSpecification 
 ResultColumn
 or ResultTableAllColumns with the columnExpressions and
 tableExpressions in the given querySelect's
 fromClause.
querySelect - public static void resolveResultTableAllColumns(QuerySelect querySelect)
querySelect's
 QueryResultSpecifications of type
 ResultTableAllColumns with the tableExpressions in the
 given querySelect's fromClause.
querySelect - public static WithTableReference resolveWithTableSpecificationReference(TableExpression potentialWithTableRef)
TableReference with the
 WithTableSpecification that is refered by the given
 potentialTableWithRef's name, if a
 TableWithSpecification is found in the
 QueryExpressionRoot that contains the given
 TableReference.
potentialTableWithRef - 
TableWithSpecification found
public static void setHavingClauseForStatement(QuerySearchCondition newSearchCon,
                                               QueryStatement statement)
newSearchCon - new QuerySearchCondition that needs to be set.statement - the SQL Statement on which new having clause needs to
        set.
public static void setHavingClauseForStatement(QuerySearchCondition newSearchCon,
                                               SQLQueryObject statement)
newSearchCon - new QuerySearchCondition that needs to be set.statement - the SQLQueryObject on which new having clause needs to
        set.
public static void setWhereClauseForStatement(QuerySearchCondition newSearchCon,
                                              QueryStatement statement)
newSearchCon - new QuerySearchCondition that needs to set.statement - the SQL Statement on which new where clause needs to
        set.
public static void setWhereClauseForStatement(QuerySearchCondition newSearchCon,
                                              SQLQueryObject statement)
newSearchCon - new QuerySearchCondition that needs to set.statement - the SQLObject on which new where clause needs to set.
public static java.lang.String stripWhiteSpace(java.lang.String sql,
                                               char delimitedIdentifierQt)
sql and
 replaces all new lines with single spaces.
 
 Note: this method does not strip comments from the given
 sql and consequently makes any given SQL that contains
 comments invalid, unless the comment is on the last line and no valid SQL
 succeeds the comment.
 
 Note performance:  this method invokes
 String.replaceAll(java.lang.String, java.lang.String) 11 times
 after walking through the SQL source two times to remove all comments and
 transforming the given sql into upper case format
 (respecting delimited identifiers).
sql - the SQL source stringdelimitedIdentifierQt - the String that is used to pre- and suffix
        delimited identifiers, commonly it is the double-quote char '"'
sql in upper case, without comments and
         with minimal whitespacepublic void addNewName(Table selectedTable)
public QueryInsertStatement createInsertStatement(java.lang.String name,
                                                  boolean addToDb)
name - addToDb - 
public QuerySelectStatement createSelectStatement(java.lang.String name)
public QueryUpdateStatement createUpdateStatement(java.lang.String name,
                                                  boolean addToDb)
name - addToDb - 
public java.lang.String getNewName(QueryInsertStatement insert)
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||