Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   Data Types and Expressions >

Literal Collection

Use the Literal Collection segment to specify values for a collection data type. For the syntax of expressions that return values of individual elements within a collection, see Collection Constructors.

Syntax

Read syntax diagramSkip visual syntax diagramLiteral Collection:
 
|--+-"--+-SET------+--{-| Literal Data |-}."-+------------------|
   |    +-MULTISET-+                         |
   |    '-LIST-----'                         |
   '-'--+-SET------+--{-| Literal Data |-}.'-'
        +-MULTISET-+
        '-LIST-----'
 
Literal Data:
 
   .-,--------------------------------------------------------------------------------------------.
   V                             (1)                                                              |
|----+-| Element Literal Value |----------------------------------------------------------------+-+--|
     |                            (2)                                                      (2)  |
     '-| Nested Quotation Marks |-------| Literal Collection |--| Nested Quotation Marks |------'
 
Notes:
  1. See Element Literal Value
  2. See Nested Quotation Marks

Usage

You can specify literal collection values for SET, MULTISET, or LIST data types.

To specify a single literal-collection value, specify the collection type and the literal values. The following SQL statement inserts four integer values into a column called set_col that was declared as SET(INT NOT NULL):

INSERT INTO table1 (set_col) VALUES ('SET{6, 9, 9, 4}');

Specify an empty collection with an empty pair of braces ( { } ) symbols. This example inserts an empty list into a column list_col that was declared as LIST(INT NOT NULL):

INSERT INTO table2 (list_col) VALUES ('LIST{}')

A pair of single ( ' ) or double ( " ) quotes must delimit the collection. In databases where delimited identifiers are enabled, however, double quotes are not valid, except to delimit SQL identifiers.

If you are passing a literal collection as an argument to an SPL routine, make sure that there is a blank space between the parentheses that surround the arguments and the quotation marks that indicate the beginning and end of the literal collection.

If you specify a collection as a literal value in a row-string literal, you can omit the quotation marks around the collection itself. Only the outermost quotation marks that delimit the row-string literal are necessary. No quotation marks need surround the nested collection type. For an example, see Literals for Nested Rows.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]