Package org.h2.command.query

# Class TableValueConstructor

java.lang.Object
org.h2.command.Prepared
org.h2.command.query.Query
org.h2.command.query.TableValueConstructor

public class TableValueConstructor extends Query
Table value constructor.

## Field Summary

### Fields inherited from class org.h2.command.Prepared

`create, parameters, prepareAlways, session, sqlStatement, sqlTokens`

## Constructor Summary

Constructors
Constructor
Description
`TableValueConstructor(SessionLocal session, ArrayList<ArrayList<Expression>> rows)`
Creates new instance of table value constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addGlobalCondition(Parameter param, int columnId, int comparisonType)`
Add a condition to the query.
`boolean`
`allowGlobalConditions()`
Check whether adding condition to the query is allowed.
`void`
`fireBeforeSelectTriggers()`
Call the before triggers on all tables.
`double`
`getCost()`
Calculate the cost to execute this query.
`Expression`
`getIfSingleRow()`
If this query is determined as a single-row query, returns a replacement expression.
`StringBuilder`
`getPlanSQL(StringBuilder builder, int sqlFlags)`
Appends the SQL statement with the execution plan.
`HashSet<Table>`
`getTables()`
Get all tables that are involved in this query.
`static void`
`getValuesSQL(StringBuilder builder, int sqlFlags, ArrayList<ArrayList<Expression>> rows)`
Appends the SQL of the values to the specified string builder..
`static void`
`getVisibleResult(SessionLocal session, ResultTarget result, Column[] columns, ArrayList<ArrayList<Expression>> rows)`
Appends visible columns of all rows to the specified result.
`void`
`init()`
Initialize the query.
`boolean`
`isConstantQuery()`
Check if this query will always return the same value and has no side effects.
`boolean`
`isEverything(ExpressionVisitor visitor)`
Check if this expression and all sub-expressions can fulfill a criteria.
`boolean`
`isUnion()`
Check if this is a UNION query.
`void`
`mapColumns(ColumnResolver resolver, int level, boolean outer)`
Map the columns to the given column resolver.
`void`
`prepareExpressions()`
`void`
`preparePlan()`
`protected ResultInterface`
`queryWithoutCache(long limit, ResultTarget target)`
Execute the query without checking the cache.
`void`
`setEvaluatable(TableFilter tableFilter, boolean b)`
Change the evaluatable flag.
`void`
`setForUpdate(ForUpdate forUpdate)`
Set the FOR UPDATE clause.
`Table`
`toTable(String alias, Column[] columnTemplates, ArrayList<Parameter> parameters, boolean forCreateView, Query topQuery)`
Converts this query to a table or a view.
`void`
`updateAggregate(SessionLocal s, int stage)`
Update all aggregate function values.

### Methods inherited from class org.h2.command.query.Query

`collectDependencies, disableCache, exists, getColumnCount, getCostAsExpression, getExpressions, getFetch, getForUpdate, getMaxDataModificationId, getOffset, getOuterQueryScope, getRowDataType, getType, hasOrder, invalidateCachedResult, isAnyDistinct, isFetchPercent, isInPredicateResult, isNeverLazy, isQuery, isReadOnly, isRetryable, isStandardDistinct, isTransactional, isWithTies, prepare, query, query, queryMeta, setDistinctIfPossible, setFetch, setFetchPercent, setInPredicateResult, setInPredicateResultSortTypes, setNeverLazy, setOffset, setOrder, setOuterQueryScope, setWithClause, setWithTies, writeWithList`

### Methods inherited from class org.h2.command.Prepared

`checkCanceled, checkParameters, getCurrentRowNumber, getDatabase, getObjectId, getParameters, getPersistedObjectId, getPlanSQL, getSession, getSimpleSQL, getSQL, getSQLTokens, isCacheable, isWithParamValues, needRecompile, setCommand, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, setWithParamValues, toString, update`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### TableValueConstructor

public TableValueConstructor(SessionLocal session, ArrayList<ArrayList<Expression>> rows)
Creates new instance of table value constructor.

Parameters:
  `session` - the session
  `rows` - the rows

## Method Details

### getVisibleResult

public static void getVisibleResult(SessionLocal session, ResultTarget result, Column[] columns, ArrayList<ArrayList<Expression>> rows)
Appends visible columns of all rows to the specified result.

Parameters:
  `session` - the session
  `result` - the result
  `columns` - the columns
  `rows` - the rows with data

### getValuesSQL

public static void getValuesSQL(StringBuilder builder, int sqlFlags, ArrayList<ArrayList<Expression>> rows)
Appends the SQL of the values to the specified string builder..

Parameters:
  `builder` - string builder
  `sqlFlags` - formatting flags
  `rows` - the values

### isUnion

public boolean isUnion()
Description copied from class: `Query`
Check if this is a UNION query.

Specified by:
  `isUnion` in class `Query`
Returns:
  `true` if this is a UNION query

### queryWithoutCache

protected ResultInterface queryWithoutCache(long limit, ResultTarget target)
Description copied from class: `Query`
Execute the query without checking the cache. If a target is specified, the results are written to it, and the method returns null. If no target is specified, a new LocalResult is created and returned.

Specified by:
  `queryWithoutCache` in class `Query`
Parameters:
  `limit` - the limit as specified in the JDBC method call
  `target` - the target to write results to
Returns:
  the result

### init

public void init()
Description copied from class: `Query`
Initialize the query.

Specified by:
  `init` in class `Query`

### prepareExpressions

public void prepareExpressions()

Specified by:
  `prepareExpressions` in class `Query`

### preparePlan

public void preparePlan()

Specified by:
  `preparePlan` in class `Query`

### getCost

public double getCost()
Description copied from class: `Query`
Calculate the cost to execute this query.

Specified by:
  `getCost` in class `Query`
Returns:
  the cost

### getTables

public HashSet<Table> getTables()
Description copied from class: `Query`
Get all tables that are involved in this query.

Specified by:
  `getTables` in class `Query`
Returns:
  the set of tables

### setForUpdate

public void setForUpdate(ForUpdate forUpdate)
Description copied from class: `Query`
Set the FOR UPDATE clause.

Specified by:
  `setForUpdate` in class `Query`
Parameters:
  `forUpdate` - the new FOR UPDATE clause

### mapColumns

public void mapColumns(ColumnResolver resolver, int level, boolean outer)
Description copied from class: `Query`
Map the columns to the given column resolver.

Specified by:
  `mapColumns` in class `Query`
Parameters:
  `resolver` - the resolver
  `level` - the subquery level (0 is the top level query, 1 is the first subquery level)
  `outer` - whether this method was called from the outer query

### setEvaluatable

public void setEvaluatable(TableFilter tableFilter, boolean b)
Description copied from class: `Query`
Change the evaluatable flag. This is used when building the execution plan.

Specified by:
  `setEvaluatable` in class `Query`
Parameters:
  `tableFilter` - the table filter
  `b` - the new value

### addGlobalCondition

public void addGlobalCondition(Parameter param, int columnId, int comparisonType)
Description copied from class: `Query`
Add a condition to the query. This is used for views.

Specified by:
  `addGlobalCondition` in class `Query`
Parameters:
  `param` - the parameter
  `columnId` - the column index (0 meaning the first column)
  `comparisonType` - the comparison type

### allowGlobalConditions

public boolean allowGlobalConditions()
Description copied from class: `Query`
Check whether adding condition to the query is allowed. This is not allowed for views that have an order by and a limit, as it would affect the returned results.

Specified by:
  `allowGlobalConditions` in class `Query`
Returns:
  true if adding global conditions is allowed

### isEverything

public boolean isEverything(ExpressionVisitor visitor)
Description copied from class: `Query`
Check if this expression and all sub-expressions can fulfill a criteria. If any part returns false, the result is false.

Specified by:
  `isEverything` in class `Query`
Parameters:
  `visitor` - the visitor
Returns:
  if the criteria can be fulfilled

### updateAggregate

public void updateAggregate(SessionLocal s, int stage)
Description copied from class: `Query`
Update all aggregate function values.

Specified by:
  `updateAggregate` in class `Query`
Parameters:
  `s` - the session
  `stage` - select stage

### fireBeforeSelectTriggers

public void fireBeforeSelectTriggers()
Description copied from class: `Query`
Call the before triggers on all tables.

Specified by:
  `fireBeforeSelectTriggers` in class `Query`

### getPlanSQL

public StringBuilder getPlanSQL(StringBuilder builder, int sqlFlags)
Description copied from class: `Prepared`
Appends the SQL statement with the execution plan.

Overrides:
  `getPlanSQL` in class `Prepared`
Parameters:
  `builder` - string builder
  `sqlFlags` - formatting flags
Returns:
  the execution plan

### toTable

public Table toTable(String alias, Column[] columnTemplates, ArrayList<Parameter> parameters, boolean forCreateView, Query topQuery)
Description copied from class: `Query`
Converts this query to a table or a view.

Overrides:
  `toTable` in class `Query`
Parameters:
  `alias` - alias name for the view
  `columnTemplates` - column templates, or `null`
  `parameters` - the parameters
  `forCreateView` - if true, a system session will be used for the view
  `topQuery` - the top level query
Returns:
  the table or the view

### isConstantQuery

public boolean isConstantQuery()
Description copied from class: `Query`
Check if this query will always return the same value and has no side effects.

Overrides:
  `isConstantQuery` in class `Query`
Returns:
  if this query will always return the same value and has no side effects.

### getIfSingleRow

public Expression getIfSingleRow()
Description copied from class: `Query`
If this query is determined as a single-row query, returns a replacement expression.

Overrides:
  `getIfSingleRow` in class `Query`
Returns:
  the expression, or `null`