invantive documentation
Invantive Support ForumsLog In / Sign Up

Use Statement

Syntax

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart TD
    stmt_start((START))
    stmt_start --> stmt_0_0[USE]:::quoted
    stmt_0_0 --> stmt_0_1[<a href="Invantive UniversalSQL/Grammar/Partition Identifiers#Partition+Identifier+with+Alias" class="internal-link">partitionIdentifierWithAlias</a>]
    stmt_0_1c --> stmt_0_1
    stmt_0_1 --> stmt_0_2[EXCLUDE]:::quoted
    stmt_0_1 --> stmt_0_3[EXCLUDING]:::quoted
    stmt_0_2 --> stmt_0_4[<a href="Invantive UniversalSQL/Grammar/Partition Identifiers#Partition+Identifier+with+Alias" class="internal-link">partitionIdentifierWithAlias</a>]
    stmt_0_4 --> stmt_0_4c[","]:::quoted
    stmt_0_4c --> stmt_0_4
    stmt_0_3 --> stmt_0_4
    stmt_0_0 --> stmt_0_5[<a href="Invantive UniversalSQL/Grammar/Query Statement/Select Statement#selectStatement" class="internal-link">selectStatement</a>]
    stmt_0_1 --> stmt_end
    stmt_0_4 --> stmt_end
    stmt_0_5 --> stmt_end((END))
    stmt_0_1 --> stmt_0_1c[","]:::quoted

Purpose

The use statement enables you to specify which partitions should be selected by subsequent DML statements such as select.

There are two ways to specify the partitions:

  • Using an expliciet list.
  • Using a query.

Using an explicit list

You can specify one or multiple partitions as a comma-separated list, possibly for a specific data container by appending an at-sign (@) plus data container alias to the partition code.

The following partition codes have a special meaning:

  • The value default specifies to use the partition(s) originally selected when you logged on to the platform providing the data container.
  • The value all selects all partitions available on a data container.

The list of partition codes selected can be reduced by another list of partitions using EXCLUDE. This is typically done when the explicit list selected all available partitions using all.

Using a query

For complex scenarios such as for accounting firms, you can specify any valid Invantive UniversalSQL select statement which returns one or two columns. Each row from the query specifies one partition to select. The first column specifies the partition code, whereas the optional second column specifies a specific data container alias.

Examples

The following example selects partition 35 in the data container with alias eolnl and partition 57345 in the data container with alias nmbrsnl:

use 35@eolnl, 57345@nmbrsnl

The following example selects all partitions except 35 in a database with only one data container, hence without alias:

use all exclude 35

The following example selects partition 35 in the data container with alias eolnl and partition 57345 in the data container with alias nmbrsnl:

use
select '35', 'eolnl'
union all 
select '57345', 'nmbrsnl'