Derived from file sql-99.bnf version 2.10 dated 2017/11/14 06:53:22
Generated on 2017-11-14 06:53:25+00:00 by file bnf2html.pl version 3.16 dated 2017/11/14 06:53:22
Using Appendix G of "SQL:1999 Understanding Relational Language Components" by J Melton and A R Simon (Morgan Kaufmann, May 2001, ISBN 0-55860-456-1) as the primary source of the syntax, here is the BNF syntax for SQL-99. The Word 97 version of this document is available from: http://www.mkp.com/books_catalog/catalog.asp?ISBN=1-55860-456-1 .
Note that this version of this file includes the corrections from ISO 9075:1999/Cor.1:2000.
The plain text version of this grammar is sql-99.bnf .
This material (starting with <SQL object identifier>) is defined in section 6.3 "Object Identifier for Database Language SQL" of ISO/IEC 9075-1:1999 (SQL Framework). It is used to express the capabilities of an implementation. The package names are identifiers such as 'PKG001', equivalent to 'Enhanced datetime facilities', as defined in the informative Annex B to SQL Framework. Each such package identifies a number of features that are provided when the SQL object identifier claims to provide the package.
<SQL provenance> <SQL variant>
<arc3> ::= 9075
<SQL edition> <SQL conformance>
<1987> | <1989> | <1992> | <1999>
<integrity no> | <integrity yes>
<low> | <intermediate> | <high>
<Part 3> <Part 4> <Part 5> <Part 6> <Part 7> <Part 8> <Part 9> <Part 10>
The parenthesized (i) and (n) are italic in the SQL standard. It is not clear exactly what this should look like, despite all the information. However, it is also not important; this is not really a part of the SQL language per se. Note that the package numbers are PKG001 to PKG009, for example. We still have to devise a mechanism to persuade bnf2yacc.pl to ignore this information.
<packages> ::= <Package PKG (i)> ...
<Part (n)> ::= <Part (n) no > | <Part (n) yes >
<Part (n) yes> ::= !! (as specified in ISO/IEC 9075-(n))
<Package PKG(i)> ::= <Package PKG (i)Yes> | <Package PKG (i)No>
<Part 4 conformance> <Part 4 module>
<Part 4 module yes> | <Part 4 module no>
<Part 5 conformance> <Part 5 direct> <Part 5 embedded>
The original used sqlbindings199x, but the x should clearly be a 9.
<Part 5 direct yes> | <Part 5 direct no>
<Part 5 embedded no> | <Part 5 embedded languages> ...
<Part 5 embedded languages> ::=
<Part 5 embedded Ada>
| <Part 5 embedded C>
| <Part 5 embedded COBOL>
| <Part 5 embedded Fortran>
| <Part 5 embedded MUMPS>
| <Part 5 embedded Pascal>
| <Part 5 embedded PL/I>
Most of this section would normally be handled within the lexical analyzer rather than in the grammar proper. Further, the original document does not quote the various single characters, which makes it hard to process automatically.
<simple Latin letter> | <digit> | <SQL special character>
<simple Latin letter> ::=
<simple Latin upper case letter>
| <simple Latin lower case letter>
<simple Latin upper case letter> ::=
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
<simple Latin lower case letter> ::=
a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<SQL special character> ::=
<space>
| <double quote>
| <percent>
| <ampersand>
| <quote>
| <left paren>
| <right paren>
| <asterisk>
| <plus sign>
| <comma>
| <minus sign>
| <period>
| <solidus>
| <colon>
| <semicolon>
| <less than operator>
| <equals operator>
| <greater than operator>
| <question mark>
| <left bracket>
| <right bracket>
| <circumflex>
| <underscore>
| <vertical bar>
| <left brace>
| <right brace>
<space> ::= !! (See the Syntax Rules)
<double quote> ::= "
<percent> ::= %
<ampersand> ::= &
<quote> ::= '
<left paren> ::= (
<right paren> ::= )
<asterisk> ::= *
<plus sign> ::= +
<comma> ::= ,
<minus sign> ::= -
<period> ::= .
<solidus> ::= /
<colon> ::= :
<semicolon> ::= ;
<less than operator> ::= <
<equals operator> ::= =
<greater than operator> ::= >
<question mark> ::= ?
<left bracket> ::= [
<right bracket> ::= ]
<circumflex> ::= ^
<underscore> ::= _
<vertical bar> ::= |
<left brace> ::= {
<right brace> ::= }
<SQL-client module definition> modified per ISO 9075:1999/Cor.1:2000(E)
<SQL-client module definition> ::=
<module name clause>
<language clause>
<module authorization clause>
[ <module path specification> ]
[ <module transform group specification> ]
[ <temporary table declaration> ... ]
<module contents> ...
<module name clause> ::=
<SQL-client module name> ] [ <module character set specification> ]
<regular identifier> | <delimited identifier>
<identifier body> modified per ISO 9075:1999/Cor.1:2000(E).
<identifier body> also rationalized by removing curly brackets around <identifier part> because they are unnecessary and inconsistent with other places where '...' modifies a single non-terminal.
<identifier start> [ <identifier part> ... ]
<initial alphabetic character> | <ideographic character>
<initial alphabetic character> ::= !! (See the Syntax Rules)
<ideographic character> ::= !! (See the Syntax Rules)
<identifier part> ::=
<alphabetic character>
| <ideographic character>
| <decimal digit character>
| <identifier combining character>
| <underscore>
| <alternate underscore>
| <extender character>
| <identifier ignorable character>
| <connector character>
<alphabetic character> ::= !! (See the Syntax Rules)
<decimal digit character> ::= !! (See the Syntax Rules)
<identifier combining character> ::= !! (See the Syntax Rules)
<alternate underscore> ::= !! (See the Syntax Rules)
<extender character> ::= !! (See the Syntax Rules)
<identifier ignorable character> ::= !! (See the Syntax Rules)
<connector character> ::= !! (See the Syntax Rules)
<double quote> <delimited identifier body> <double quote>
<delimited identifier part> ...
<nondoublequote character> | <doublequote symbol>
<nondoublequote character> ::= !! (See the Syntax Rules)
Note that the two successive double quote characters must have no other character (such as a space) between them. The lexical analyzer would normally deal with this sort of issue.
<character set specification> ::=
<standard character set name>
| <implementation-defined character set name>
| <user-defined character set name>
<schema name> <period> ] <SQL language identifier>
<catalog name> <period> ] <unqualified schema name>
<SQL language identifier> ::=
<SQL language identifier start> [ { <underscore> | <SQL language identifier part> }... ]
<simple Latin letter> | <digit>
<language name> ::= ADA | C | COBOL | FORTRAN | MUMPS | PASCAL | PLI | SQL
<role name> | <user identifier>
<schema name> [ { <comma> <schema name> }... ]
<transform group specification>
<transform group specification> ::=
<single group specification> | <multiple group specification> }
<group specification> [ { <comma> <group specification> }... ]
<group name> <user-defined type>
<schema name> <period> ] <qualified identifier>
<temporary table declaration> ::=
<table name>
<table element list>
[ <table commit action> ROWS ]
<local or schema qualified name>
<local or schema qualifier> <period> ] <qualified identifier>
<table element list> ::=
<left paren> <table element> [ { <comma> <table element> }... ] <right paren>
<table element> ::=
<column definition>
| <table constraint definition>
| <like clause>
| <self-referencing column specification>
| <column options>
<column definition> ::=
<column name>
{ <data type> | <domain name> }
[ <reference scope check> ]
[ <default clause> ]
[ <column constraint definition> ... ]
[ <collate clause> ]
<data type> ::=
<predefined type>
| <row type>
| <user-defined type>
| <reference type>
| <collection type>
<predefined type> ::=
<character string type> [ <character set specification> ]
| <national character string type>
| <binary large object string type>
| <bit string type>
| <numeric type>
| <boolean type>
| <datetime type>
| <interval type>
<character string type> ::=
<left paren> <length> <right paren> ]
| <left paren> <length> <right paren> ]
| <left paren> <length> <right paren>
| <left paren> <length> <right paren>
| <left paren> <length> <right paren>
| <left paren> <large object length> <right paren> ]
| <left paren> <large object length> <right paren> ]
| <left paren> <large object length> <right paren> ]
<digit> ...
<unsigned integer> [ <multiplier> ] | <large object length token>
<multiplier> ::= K | M | G
<digit> ... <multiplier>
<national character string type> ::=
<left paren> <length> <right paren> ]
| <left paren> <length> <right paren> ]
| <left paren> <length> <right paren> ]
| <left paren> <length> <right paren>
| <left paren> <length> <right paren>
| <left paren> <length> <right paren>
| <left paren> <large object length> <right paren> ]
| <left paren> <large object length> <right paren> ]
| <left paren> <large object length> <right paren> ]
<binary large object string type> ::=
<left paren> <large object length> <right paren> ]
| <left paren> <large object length> <right paren> ]
<bit string type> ::=
<left paren> <length> <right paren> ]
| <left paren> <length> <right paren>
<exact numeric type> | <approximate numeric type>
<exact numeric type> ::=
<left paren> <precision> [ <comma> <scale> ] <right paren> ]
| <left paren> <precision> [ <comma> <scale> ] <right paren> ]
| <left paren> <precision> [ <comma> <scale> ] <right paren> ]
| INTEGER
| INT
| SMALLINT
<approximate numeric type> ::=
<left paren> <precision> <right paren> ]
| REAL
| DOUBLE PRECISION
<datetime type> ::=
<left paren> <time precision> <right paren> ] [ <with or without time zone> ]
| <left paren> <timestamp precision> <right paren> ] [ <with or without time zone> ]
<time fractional seconds precision>
<with or without time zone> ::= WITH TIME ZONE | WITHOUT TIME ZONE
<time fractional seconds precision>
<start field> <end field> | <single datetime field>
<start field> ::=
<non-second primary datetime field> [ <left paren> <interval leading field precision> <right paren> ]
<non-second primary datetime field> ::= YEAR | MONTH | DAY | HOUR | MINUTE
<end field> ::=
<non-second primary datetime field>
| <left paren> <interval fractional seconds precision> <right paren> ]
<single datetime field> ::=
<non-second primary datetime field> [ <left paren> <interval leading field precision> <right paren> ]
| <left paren> <interval leading field precision> [ <comma> <interval fractional seconds precision> ] <right paren> ]
<left paren> <field definition> [ { <comma> <field definition> }... ] <right paren>
<field name> <data type> [ <reference scope check> ] [ <collate clause> ]
<reference scope check> ::=
<reference scope check action> ]
<referential action> ::=
CASCADE
| SET NULL
| SET DEFAULT
| RESTRICT
| NO ACTION
<schema name> <period> ] <qualified identifier>
<left paren> <referenced type> <right paren> [ <scope clause> ]
<data type> <array specification>
<array specification> ::=
<collection type constructor> <left bracket or trigraph> <unsigned integer> <right bracket or trigraph>
<collection type constructor> ::= ARRAY
<left bracket> | <left bracket trigraph>
The trigraphs are strictly sequences of characters, not sequences of tokens. There may not be any spaces between the characters. Normally, the lexical analyzer would return the trigraphs as a simple symbol.
<question mark> <question mark> <left paren>
<right bracket> | <right bracket trigraph>
<question mark> <question mark> <right paren>
<default option> ::=
<literal>
| <datetime value function>
| <implicitly typed value specification>
<signed numeric literal> | <general literal>
<sign> ] <unsigned numeric literal>
<exact numeric literal> | <approximate numeric literal>
<exact numeric literal> ::=
<unsigned integer> [ <period> [ <unsigned integer> ] ]
| <period> <unsigned integer>
<general literal> ::=
<character string literal>
| <national character string literal>
| <bit string literal>
| <hex string literal>
| <binary string literal>
| <datetime literal>
| <interval literal>
| <boolean literal>
<character string literal> ::=
[ <introducer> <character set specification> ]
<quote> [ <character representation> ... ] <quote>
[ { <separator> <quote> [ <character representation> ... ] <quote> }... ]
<nonquote character> | <quote symbol>
<nonquote character> ::= !! (See the Syntax Rules.)
The <quote symbol> rule consists of two immediately adjacent <quote> marks with no spaces. As usual, this would be best handled in the lexical analyzer, not in the grammar.
<comment> | <white space> }...
<simple comment> | <bracketed comment>
<simple comment introducer> [ <comment character> ... ] <newline>
<minus sign> <minus sign> [ <minus sign> ... ]
<nonquote character> | <quote>
<newline> ::= !! (See the Syntax Rules)
The <bracketed comment> rule included '!! (See the Syntax Rules)'. This probably says something about the <slash> <asterisk> and <asterisk> <slash> needing to be adjacent characters rather than adjacent tokens.
<bracketed comment> ::=
<bracketed comment introducer> <bracketed comment contents> <bracketed comment terminator>
<comment character> | <separator> }... ]
<white space> ::= !! (See the Syntax Rules)
<national character string literal> ::=
<quote> [ <character representation> ... ] <quote>
[ { <separator> <quote> [ <character representation> ... ] <quote> }... ]
<bit string literal> ::=
<quote> [ <bit> ... ] <quote>
[ { <separator> <quote> [ <bit> ... ] <quote> }... ]
<hex string literal> ::=
<quote> [ <hexit> ... ] <quote>
[ { <separator> <quote> [ <hexit> ... ] <quote> }... ]
<digit> | A | B | C | D | E | F | a | b | c | d | e | f
<binary string literal> ::=
<quote> [ { <hexit> <hexit> }... ] <quote>
[ { <separator> <quote> [ { <hexit> <hexit> }... ] <quote> }... ]
<date literal> | <time literal> | <timestamp literal>
<quote> <unquoted date string> <quote>
<years value> <minus sign> <months value> <minus sign> <days value>
<quote> <unquoted time string> <quote>
<time value> [ <time zone interval> ]
<hours value> <colon> <minutes value> <colon> <seconds value>
<seconds integer value> [ <period> [ <seconds fraction> ] ]
<sign> <hours value> <colon> <minutes value>
<quote> <unquoted timestamp string> <quote>
<unquoted date string> <space> <unquoted time string>
<sign> ] <interval string> <interval qualifier>
<quote> <unquoted interval string> <quote>
<sign> ] { <year-month literal> | <day-time literal> }
<years value> | [ <years value> <minus sign> ] <months value>
<day-time interval> | <time interval>
<day-time interval> ::=
<days value> [ <space> <hours value> [ <colon> <minutes value> [ <colon> <seconds value> ] ] ]
<time interval> ::=
<hours value> [ <colon> <minutes value> [ <colon> <seconds value> ] ]
| <minutes value> [ <colon> <seconds value> ]
| <seconds value>
<boolean literal> ::= TRUE | FALSE | UNKNOWN
<datetime value function> ::=
<current date value function>
| <current time value function>
| <current timestamp value function>
| <current local time value function>
| <current local timestamp value function>
<current date value function> ::= CURRENT_DATE
<current time value function> ::=
<left paren> <time precision> <right paren> ]
<current timestamp value function> ::=
<left paren> <timestamp precision> <right paren> ]
<current local time value function> ::=
<left paren> <time precision> <right paren> ]
<current local timestamp value function> ::=
<left paren> <timestamp precision> <right paren> ]
<null specification> | <empty specification>
<left bracket or trigraph> <right bracket or trigraph>
<column constraint definition> ::=
[ <constraint name definition> ] <column constraint> [ <constraint characteristics> ]
<column constraint> ::=
<unique specification>
| <references specification>
| <check constraint definition>
<unique specification> ::= UNIQUE | PRIMARY KEY
<references specification> ::=
<referenced table and columns>
[ <match type> ] [ <referential triggered action> ]
<referenced table and columns> ::=
<table name> [ <left paren> <reference column list> <right paren> ]
<column name> [ { <comma> <column name> }... ]
<match type> ::= FULL | PARTIAL | SIMPLE
<referential triggered action> ::=
<update rule> [ <delete rule> ]
| <delete rule> [ <update rule> ]
<left paren> <search condition> <right paren>
<boolean value expression> ::=
<boolean term>
| <boolean value expression> <boolean term>
<boolean term> ::=
<boolean factor>
| <boolean term> <boolean factor>
<boolean primary> [ <truth value> ]
<boolean primary> ::=
<predicate>
| <parenthesized boolean value expression>
| <nonparenthesized value expression primary>
<predicate> ::=
<comparison predicate>
| <between predicate>
| <in predicate>
| <like predicate>
| <null predicate>
| <quantified comparison predicate>
| <exists predicate>
| <unique predicate>
| <match predicate>
| <overlaps predicate>
| <similar predicate>
| <distinct predicate>
| <type predicate>
<row value expression> <comp op> <row value expression>
<row value special case> | <row value constructor>
<value specification> | <value expression>
<literal> | <general value specification>
<general value specification> ::=
<host parameter specification>
| <SQL parameter reference>
| <SQL variable reference>
| <dynamic parameter specification>
| <embedded variable specification>
| <user-defined type>
| CURRENT_USER
| SESSION_USER
| SYSTEM_USER
| USER
| VALUE
<host parameter name> [ <indicator parameter> ]
<identifier> [ { <period> <identifier> }... ]
<value expression> ::=
<numeric value expression>
| <string value expression>
| <datetime value expression>
| <interval value expression>
| <boolean value expression>
| <user-defined type value expression>
| <row value expression>
| <reference value expression>
| <collection value expression>
<numeric value expression> ::=
<term>
| <numeric value expression> <plus sign> <term>
| <numeric value expression> <minus sign> <term>
<term> ::=
<factor>
| <term> <asterisk> <factor>
| <term> <solidus> <factor>
<numeric primary> ::=
<value expression primary>
| <numeric value function>
<value expression primary> ::=
<parenthesized value expression>
| <nonparenthesized value expression primary>
<left paren> <value expression> <right paren>
<nonparenthesized value expression primary> ::=
<unsigned value specification>
| <column reference>
| <set function specification>
| <scalar subquery>
| <case expression>
| <cast specification>
| <subtype treatment>
| <attribute or method reference>
| <reference resolution>
| <collection value constructor>
| <routine invocation>
| <field reference>
| <element reference>
| <method invocation>
| <static method invocation>
| <new specification>
<unsigned literal> | <general value specification>
<unsigned numeric literal> | <general literal>
<column reference> ::=
<basic identifier chain>
| <period> <qualified identifier> <period> <column name>
<set function specification> ::=
<left paren> <asterisk> <right paren>
| <general set function>
| <grouping operation>
<general set function> ::=
<set function type> <left paren> [ <set quantifier> ] <value expression> <right paren>
<computational operation> ::= AVG | MAX | MIN | SUM | EVERY | ANY | SOME | COUNT
<set quantifier> ::= DISTINCT | ALL
<left paren> <column reference> <right paren>
<left paren> <query expression> <right paren>
<with clause> ] <query expression body>
<with list element> [ { <comma> <with list element> }... ]
<with list element> ::=
<query name>
[ <left paren> <with column list> <right paren> ]
<left paren> <query expression> <right paren>
[ <search or cycle clause> ]
<search or cycle clause> ::=
<search clause>
| <cycle clause>
| <search clause> <cycle clause>
<search clause> ::=
<recursive search order> <sequence column>
<recursive search order> ::=
<sort specification list>
| <sort specification list>
<sort specification> [ { <comma> <sort specification> }... ]
<sort specification> modified per ISO 9075:1999/Cor.1:2000(E)
<sort key> [ <ordering specification> ]
<ordering specification> ::= ASC | DESC
<cycle clause> ::=
<cycle column list>
<cycle mark column> <cycle mark value>
<non-cycle mark value>
<path column>
<cycle column> [ { <comma> <cycle column> }... ]
<non-join query expression> | <joined table>
<non-join query expression> ::=
<non-join query term>
| <query expression body> <corresponding spec> ] <query term>
| <query expression body> <corresponding spec> ] <query term>
<non-join query term> ::=
<non-join query primary>
| <query term> <corresponding spec> ] <query primary>
<non-join query primary> ::=
<simple table>
| <left paren> <non-join query expression> <right paren>
<query specification> | <table value constructor> | <explicit table>
<set quantifier> ] <select list> <table expression>
<asterisk> | <select sublist> [ { <comma> <select sublist> }... ]
<derived column> | <qualified asterisk>
<value expression> [ <as clause> ]
<qualified asterisk> ::=
<asterisked identifier chain> <period> <asterisk>
| <all fields reference>
<asterisked identifier> [ { <period> <asterisked identifier> }... ]
<value expression primary> <period> <asterisk>
<from clause> [ <where clause> ] [ <group by clause> ] [ <having clause> ]
<table reference> [ { <comma> <table reference> }... ]
<table primary> | <joined table>
<table primary> ::=
<table or query name> [ [ <correlation name> [ <left paren> <derived column list> <right paren> ] ]
| <derived table> [ <correlation name> [ <left paren> <derived column list> <right paren> ]
| <lateral derived table> [ <correlation name> [ <left paren> <derived column list> <right paren> ]
| <collection derived table> [ <correlation name> [ <left paren> <derived column list> <right paren> ]
| <only spec> [ [ <correlation name> [ <left paren> <derived column list> <right paren> ] ]
| <left paren> <joined table> <right paren>
<left paren> <query expression> <right paren>
<collection derived table> ::=
<left paren> <collection value expression> <right paren> [ WITH ORDINALITY ]
<left paren> <table or query name> <right paren>
<cross join> | <qualified join> | <natural join> | <union join>
<table reference> <table primary>
<table reference> [ <join type> ] <table reference> <join specification>
<outer join type> ::= LEFT | RIGHT | FULL
<join condition> | <named columns join>
<left paren> <join column list> <right paren>
<table reference> <join type> ] <table primary>
<table reference> <table primary>
Rules from <group by clause> to <grouping set> modified per ISO 9075:1999/Cor.1:2000(E)
<grouping element> [ { <comma> <grouping element> }... ]
<grouping element> ::=
<ordinary grouping set>
| <rollup list>
| <cube list>
| <grouping sets specification>
| <grand total>
<column reference> [ <collate clause> ]
<left paren> <grouping column reference list> <right paren>
<grouping column reference list> ::=
<grouping column reference> [ { <comma> <grouping column reference> }... ]
<left paren> <grouping column reference list> <right paren>
<left paren> <grouping set list> <right paren>
<grouping set> [ { <comma> <grouping set> }... ]
<grouping set> ::=
<ordinary grouping set>
| <rollup list>
| <cube list>
| <grouping sets specification>
| <grand total>
<ordinary grouping set> ::=
<grouping column reference>
| <left paren> <grouping column reference list> <right paren>
<grouping set> <comma> <grouping set list>
<row value expression> [ { <comma> <row value expression> }... ]
<non-join query term> | <joined table>
<corresponding spec> ::=
<left paren> <corresponding column list> <right paren> ]
<non-join query primary> | <joined table>
<case abbreviation> | <case specification>
<case abbreviation> ::=
<left paren> <value expression> <comma> <value expression> <right paren>
| <left paren> <value expression> { <comma> <value expression> }... <right paren>
<simple case> | <searched case>
<case operand> <simple when clause> ... [ <else clause> ] END
<searched when clause> ... [ <else clause> ] END
<left paren> <cast operand> <cast target> <right paren>
<value expression> | <implicitly typed value specification>
<subtype treatment> to <target subtype> modified per ISO 9075:1999/Cor.1:2000(E)
<subtype treatment> ::=
<left paren> <subtype operand> <target subtype> <right paren>
<attribute or method reference> ::=
<value expression primary> <dereference operator> <qualified identifier>
[ <SQL argument list> ]
<right arrow> ::= ->
<SQL argument list> ::=
<left paren> [ <SQL argument> [ { <comma> <SQL argument> }... ] ] <right paren>
<value expression> | <generalized expression> | <target specification>
<value expression> <user-defined type>
<target specification> ::=
<host parameter specification>
| <SQL parameter reference>
| <column reference>
| <SQL variable reference>
| <dynamic parameter specification>
| <embedded variable specification>
<left paren> <reference value expression> <right paren>
<array value constructor> | <array concatenation> | <value expression primary>
<array value list constructor>
<array value list constructor> ::=
<left bracket or trigraph> <array element list> <right bracket or trigraph>
<array element> [ { <comma> <array element> }... ]
<array concatenation> ::=
<array value expression 1> <concatenation operator> <array value expression 2>
<concatenation operator> ::= ||
<routine name> <SQL argument list>
<schema name> <period> ] <qualified identifier>
<value expression primary> <period> <field name>
<element reference> ::=
<array value expression> <left bracket or trigraph> <numeric value expression> <right bracket or trigraph>
<direct invocation> | <generalized invocation>
<direct invocation> ::=
<value expression primary> <period> <method name> [ <SQL argument list> ]
<generalized invocation> ::=
<left paren> <value expression primary>
<data type> <right paren> <period> <method name>
[ <SQL argument list> ]
It is not remotely clear why this was needed in this grammar. <constructor method selection> added per ISO 9075:1999/Cor.1:2000(E)
<static method invocation> ::=
<user-defined type> <double colon> <method name> [ <SQL argument list> ]
Note that <double colon> must be a pair of characters with no intervening space, not a pair of colon symbols separated by arbitrary white space. Normally, the lexical analyzer would return <double colon> as a symbol.
<numeric value function> ::=
<position expression>
| <extract expression>
| <length expression>
| <cardinality expression>
| <absolute value expression>
| <modulus expression>
<string position expression> | <blob position expression>
<string position expression> ::=
<left paren> <string value expression> <string value expression> <right paren>
<character value expression> | <bit value expression> | <blob value expression>
<concatenation> | <character factor>
<character value expression> <concatenation operator> <character factor>
<character primary> [ <collate clause> ]
<value expression primary> | <string value function>
<character value function> | <blob value function> | <bit value function>
<character value function> ::=
<character substring function>
| <regular expression substring function>
| <fold>
| <form-of-use conversion>
| <character translation>
| <trim function>
| <character overlay function>
| <specific type method>
<character substring function> ::=
<left paren> <character value expression> <start position>
[ <string length> ] <right paren>
<regular expression substring function> modified per ISO 9075:1999/Cor.1:2000(E)
<regular expression substring function> ::=
<left paren> <character value expression> <character value expression> <escape character> <right paren>
<left paren> <character value expression> <right paren>
<form-of-use conversion> ::=
<left paren> <character value expression>
<form-of-use conversion name> <right paren>
<character translation> ::=
<left paren> <character value expression>
<translation name> <right paren>
<left paren> <trim operands> <right paren>
<trim specification> ] [ <trim character> ] <trim source>
<trim specification> ::= LEADING | TRAILING | BOTH
<character overlay function> ::=
<left paren> <character value expression> <character value expression>
<start position> [ <string length> ] <right paren>
<user-defined type value expression> <period> SPECIFICTYPE
<blob substring function> | <blob trim function> | <blob overlay function>
<blob substring function> ::=
<left paren> <blob value expression> <start position>
[ <string length> ] <right paren>
<blob concatenation> | <blob factor>
<blob value expression> <concatenation operator> <blob factor>
<value expression primary> | <string value function>
<left paren> <blob trim operands> <right paren>
<trim specification> ] [ <trim octet> ] <blob trim source>
<blob overlay function> ::=
<left paren> <blob value expression> <blob value expression>
<start position> [ <string length> ] <right paren>
<bit substring function> ::=
<left paren> <bit value expression> <start position>
[ <string length> ] <right paren>
<bit concatenation> | <bit factor>
<bit value expression> <concatenation operator> <bit factor>
<value expression primary> | <string value function>
<blob position expression> ::=
<left paren> <blob value expression> <blob value expression> <right paren>
<extract expression> ::=
<left paren> <extract field> <extract source> <right paren>
<primary datetime field> | <time zone field>
<non-second primary datetime field> | SECOND
<time zone field> ::= TIMEZONE_HOUR | TIMEZONE_MINUTE
<datetime value expression> | <interval value expression>
<datetime value expression> ::=
<datetime term>
| <interval value expression> <plus sign> <datetime term>
| <datetime value expression> <plus sign> <interval term>
| <datetime value expression> <minus sign> <interval term>
<interval term> ::=
<interval factor>
| <interval term 2> <asterisk> <factor>
| <interval term 2> <solidus> <factor>
| <term> <asterisk> <interval factor>
<interval absolute value function>
<left paren> <interval value expression> <right paren>
<interval value expression> ::=
<interval term>
| <interval value expression 1> <plus sign> <interval term 1>
| <interval value expression 1> <minus sign> <interval term 1>
| <left paren> <datetime value expression> <minus sign>
<datetime term> <right paren> <interval qualifier>
<datetime primary> [ <time zone> ]
<value expression primary> | <datetime value function>
<char length expression> | <octet length expression> | <bit length expression>
<char length expression> ::=
{ <left paren> <string value expression> <right paren>
<octet length expression> ::=
<left paren> <string value expression> <right paren>
<bit length expression> ::=
<left paren> <string value expression> <right paren>
<cardinality expression> ::=
<left paren> <collection value expression> <right paren>
<absolute value expression> ::=
<left paren> <numeric value expression> <right paren>
<modulus expression> ::=
<left paren> <numeric value expression dividend> <comma> <numeric value expression divisor> <right paren>
<row value constructor> ::=
<row value constructor element>
| [ <left paren> <row value constructor element list> <right paren>
| <row subquery>
<row value constructor element list> ::=
<row value constructor element> [ { <comma> <row value constructor element> }... ]
<comp op> ::=
<equals operator>
| <not equals operator>
| <less than operator>
| <greater than operator>
| <less than or equals operator>
| <greater than or equals operator>
The <not equals>, <less than or equals operator> and <greater than or equals operator> should be handled by the lexical analyzer as token symbols, not by the grammar. As usual, spaces are not allowed between the two characters.
<less than operator> <greater than operator>
<less than operator> <equals operator>
<greater than operator> <equals operator>
<between predicate> ::=
<row value expression> [ <row value expression> <row value expression>
<row value expression> [ <in predicate value>
<table subquery> | <left paren> <in value list> <right paren>
Previously, the expression in curly braces was not in square brackets. Consequently, every <in value list> had to have at least two items in it.
<row value expression> [ { <comma> <row value expression> }... ]
<character like predicate> | <octet like predicate>
<character like predicate> ::=
<character match value> [ <character pattern> [ <escape character> ]
<octet like predicate> ::=
<octet match value> [ <octet pattern> [ <escape octet> ]
<row value expression> IS [ NOT ] NULL
<row value expression> <comp op> <quantifier> <table subquery>
<match predicate> ::=
<row value expression> <table subquery>
<row value expression 1> <row value expression 2>
<similar predicate> ::=
<character match value> [ <similar pattern> [ <escape character> ]
These regular expressions are not referenced anywhere else in the document, but define the structure that the <character value expression> used in <similar pattern> must have. Structurally, these regular expressions are similar to 'egrep' expressions, except they use underscore in place of dot, and percent is equivalent to dot star in 'egrep'. The other omission is the use of caret (aka circumflex) to mark the start of the matched text and dollar to mark the end of the matched text.
<regular expression> ::=
<regular term>
| <regular expression> <vertical bar> <regular term>
<regular term> ::=
<regular factor>
| <regular term> <regular factor>
<regular factor> ::=
<regular primary>
| <regular primary> <asterisk>
| <regular primary> <plus sign>
<regular primary> ::=
<character specifier>
| <percent>
| <regular character set>
| <left paren> <regular expression> <right paren>
<non-escaped character> | <escaped character>
<non-escaped character> ::= !! (See the Syntax Rules)
<escaped character> ::= !! (See the Syntax Rules)
<regular character set> ::=
<underscore>
| <left bracket> <character enumeration> ... <right bracket>
| <left bracket> <circumflex> <character enumeration> ... <right bracket>
| <left bracket> <colon> <regular character set identifier> <colon> <right bracket>
<character enumeration> ::=
<character specifier>
| <character specifier> <minus sign> <character specifier>
<distinct predicate> ::=
<row value expression 3> <row value expression 4>
<type predicate> ::=
<user-defined type value expression> <left paren> <type list> <right paren>
<type list> ::=
<user-defined type specification> [ { <comma> <user-defined type specification> }... ]
<user-defined type specification> ::=
<inclusive user-defined type specification>
| <exclusive user-defined type specification>
<left paren> <boolean value expression> <right paren>
<truth value> ::= TRUE | FALSE | UNKNOWN
<constraint characteristics> ::=
<constraint check time> [ [ <constraint check time> ]
<constraint check time> ::= INITIALLY DEFERRED | INITIALLY IMMEDIATE
<table constraint definition> ::=
[ <constraint name definition> ] <table constraint> [ <constraint characteristics> ]
<unique constraint definition> | <referential constraint definition> | <check constraint definition>
The standard documents UNIQUE ( VALUE ) but there is no explanation of why that is different from the UNIQUE <left paren> VALUE <right paren> used here.
<unique constraint definition> ::=
<unique specification> <left paren> <unique column list> <right paren>
| <left paren> <right paren>
<referential constraint definition> ::=
<left paren> <referencing columns> <right paren> <references specification>
<self-referencing column specification> ::=
<self-referencing column name> <reference generation>
<reference generation> ::= SYSTEM GENERATED | USER GENERATED | DERIVED
<column name> <column option list>
<column option list> ::=
[ <scope clause> ] [ <default clause> ] [ <column constraint definition> ... ] [ <collate clause> ]
<table commit action> ::= PRESERVE | DELETE
<module contents> ::=
<declare cursor>
| <externally-invoked procedure>
| <dynamic declare cursor>
<declare cursor> ::=
<cursor name> [ <cursor sensitivity> ] [ <cursor scrollability> ] <cursor holdability> ] [ <cursor returnability> ] <cursor specification>
<local qualifier> <period> ] <qualified identifier>
<cursor sensitivity> ::= SENSITIVE | INSENSITIVE | ASENSITIVE
<cursor scrollability> ::= SCROLL | NO SCROLL
<cursor holdability> ::= WITH HOLD | WITHOUT HOLD
<cursor returnability> ::= WITH RETURN | WITHOUT RETURN
<query expression> [ <order by clause> ] [ <updatability clause> ]
<externally-invoked procedure> ::=
<procedure name>
<host parameter declaration setup> <semicolon>
<SQL procedure statement> <semicolon>
<host parameter declaration setup> modified per ISO 9075:1999/Cor.1:2000(E)
<host parameter declaration list>
<host parameter declaration list> ::=
<left paren> <host parameter declaration>
[ { <comma> <host parameter declaration> }... ] <right paren>
<host parameter declaration> ::=
<host parameter name> <host parameter data type>
| <status parameter>
<data type> [ <locator indication> ]
<locator indication> ::= AS LOCATOR
<status parameter> ::= SQLSTATE
<SQL executable statement> ::=
<SQL schema statement>
| <SQL data statement>
| <SQL control statement>
| <SQL transaction statement>
| <SQL connection statement>
| <SQL session statement>
| <SQL diagnostics statement>
| <SQL dynamic statement>
<SQL schema statement> ::=
<SQL schema definition statement>
| <SQL schema manipulation statement>
<SQL schema definition statement> modified per ISO 9075:1999/Cor.1:2000(E)
<SQL schema definition statement> ::=
<schema definition>
| <table definition>
| <view definition>
| <SQL-invoked routine>
| <grant statement>
| <role definition>
| <domain definition>
| <character set definition>
| <collation definition>
| <translation definition>
| <assertion definition>
| <trigger definition>
| <user-defined type definition>
| <user-defined cast definition>
| <user-defined ordering definition>
| <transform definition>
| <SQL-server module definition>
<schema definition> ::=
<schema name clause> [ <schema character set or path> ]
[ <schema element> ... ]
<schema name clause> ::=
<schema name>
| <schema authorization identifier>
| <schema name> <schema authorization identifier>
<schema character set or path> ::=
<schema character set specification>
| <schema path specification>
| <schema character set specification> <schema path specification>
| <schema path specification> <schema character set specification>
<schema character set specification> ::=
<character set specification>
<schema element> modified per ISO 9075:1999/Cor.1:2000(E)
<schema element> ::=
<table definition>
| <view definition>
| <domain definition>
| <character set definition>
| <collation definition>
| <translation definition>
| <assertion definition>
| <trigger definition>
| <user-defined type definition>
| <schema routine>
| <grant statement>
| <role definition>
| <user-defined cast definition>
| <user-defined ordering definition>
| <transform definition>
<table definition> ::=
<table scope> ] <table name> <table contents source>
[ <table commit action> ROWS ]
<global or local> ::= GLOBAL | LOCAL
<table contents source> ::=
<table element list>
| <user-defined type> [ <subtable clause> ] [ <table element list> ]
<view definition> ::=
<table name> <view specification>
<query expression> [ <levels clause> ] CHECK OPTION ]
<regular view specification> | <referenceable view specification>
<left paren> <view column list> <right paren> ]
<user-defined type> [ <subview clause> ] [ <view element list> ]
<view element list> ::=
<left paren> [ <self-referencing column specification> <comma> ]
<view element> [ { <comma> <view element> }... ] <right paren>
<levels clause> ::= CASCADED | LOCAL
<domain definition> ::=
<domain name> [ <data type>
[ <default clause> ] [ <domain constraint> ... ] [ <collate clause> ]
<domain constraint> ::=
[ <constraint name definition> ] <check constraint definition> [ <constraint characteristics> ]
<character set definition> ::=
<character set name>
[ <character set source> [ <collate clause> ]
<collation definition> ::=
<collation name> <character set specification>
<existing collation name> [ <pad characteristic> ]
<pad characteristic> ::= NO PAD | PAD SPACE
<translation definition> ::=
<translation name> <source character set specification>
<target character set specification> <translation source>
<existing translation name> | <translation routine>
<specific routine designator> modified per ISO 9075:1999/Cor.1:2000(E)
<specific routine designator> ::=
<routine type> <specific name>
| <routine type> <member name> [ <user-defined type name> ]
<specific routine designator> modified per ISO 9075:1999/Cor.1:2000(E)
<routine type> ::=
ROUTINE | FUNCTION | PROCEDURE
| [ INSTANCE | STATIC | CONSTRUCTOR ] METHOD
<schema qualified routine name> [ <data type list> ]
<data type list> ::=
<left paren> [ <data type> [ { <comma> <data type> }... ] ] <right paren>
<assertion definition> ::=
<constraint name>
<left paren> <search condition> <right paren> [ <constraint characteristics> ]
<trigger definition> ::=
<trigger name> <trigger action time> <trigger event>
<table name> [ <old or new values alias list> ] <triggered action>
<trigger action time> ::= BEFORE | AFTER
<old or new values alias> ::=
<old values correlation name>
| <new values correlation name>
| <old values table alias>
| <new values table alias>
<triggered action> ::=
[ <left paren> <search condition> <right paren> ] <triggered SQL statement>
<user-defined type body> modified per ISO 9075:1999/Cor.1:2000(E)
<user-defined type body> ::=
<user-defined type name> [ <subtype clause> ] [ <representation> ]
[ <instantiable clause> ] <finality> [ <reference type specification> ]
[ <ref cast option> ] [ <cast option> ] [ <method specification list> ]
<predefined type> | <member list>
<left paren> <member> [ { <comma> <member> }... ] <right paren>
<attribute definition> ::=
<attribute name> <data type> [ <reference scope check> ] [ <attribute default> ]
[ <collate clause> ]
<instantiable clause> ::= INSTANTIABLE | NOT INSTANTIABLE
<finality> ::= FINAL | NOT FINAL
<user-defined representation> | <derived representation> | <system-generated representation>
<cast to ref> ] [ <cast to type> ]
<cast to ref> ::=
<left paren> <right paren> <cast to ref identifier>
<cast to type> ::=
<left paren> <right paren> <cast to type identifier>
<list of attributes> ::=
<left paren> <attribute name> [ { <comma> <attribute name> }...] <right paren>
<system-generated representation> ::= REF IS SYSTEM GENERATED
<cast to distinct> ] [ <cast to source> ]
<cast to distinct> ::=
<left paren> <right paren> <cast to distinct identifier>
<cast to source> ::=
<left paren> <right paren> <cast to source identifier>
<method specification> [ { <comma> <method specification> }... ]
<original method specification> | <overriding method specification>
<original method specification> ::=
<partial method specification> [ <method characteristics> ]
<partial method specification> modified per ISO 9075:1999/Cor.1:2000(E)
<partial method specification> ::=
[ <method name>
<SQL parameter declaration list> <returns clause> [ <specific method name> ]
<SQL parameter declaration list> ::=
<left paren> [ <SQL parameter declaration>
[ { <comma> <SQL parameter declaration> }... ] ] <right paren>
<SQL parameter declaration> ::=
[ <parameter mode> ] [ <SQL parameter name> ] <parameter type> [ RESULT ]
<parameter mode> ::= IN | OUT | INOUT
<data type> [ <locator indication> ]
<returns data type> [ <result cast> ]
<data type> [ <locator indication> ]
<data type> [ <locator indication> ]
<specific method name> added per ISO 9075:1999/Cor.1:2000(E)
<schema name> <period> ] <qualified identifier>
<method characteristic> modified per ISO 9075:1999/Cor.1:2000(E)
<method characteristic> ::=
<language clause>
| <parameter style clause>
| <deterministic characteristic>
| <SQL-data access indication>
| <null-call clause>
<parameter style> ::= SQL | GENERAL
<deterministic characteristic> ::= DETERMINISTIC | NOT DETERMINISTIC
<SQL-data access indication> ::=
NO SQL
| CONTAINS SQL
| READS SQL DATA
| MODIFIES SQL DATA
<null-call clause> ::=
RETURNS NULL ON NULL INPUT
| CALLED ON NULL INPUT
<partial method specification>
<schema procedure> | <schema function>
<SQL-invoked procedure> ::=
<schema qualified routine name>
<SQL parameter declaration list> <routine characteristics> <routine body>
<routine characteristic> ... ]
<routine characteristic> modified per ISO 9075:1999/Cor.1:2000(E)
<routine characteristic> ::=
<language clause>
| <parameter style clause>
| <specific name>
| <deterministic characteristic>
| <SQL-data access indication>
| <null-call clause>
| <dynamic result sets characteristic>
<dynamic result sets characteristic> ::=
<maximum dynamic result sets>
<SQL routine body> | <external body reference>
<external body reference> modified per ISO 9075:1999/Cor.1:2000(E)
<external body reference> ::=
<external routine name> ] [ <parameter style clause> ]
[ <transform group specification> ] [ <external security clause> ]
<identifier> | <character string literal>
<external security clause> ::=
EXTERNAL SECURITY DEFINER
| EXTERNAL SECURITY INVOKER
| EXTERNAL SECURITY IMPLEMENTATION DEFINED
<SQL-invoked function> ::=
{ <function specification> | <method specification designator> } <routine body>
<function specification> ::=
<schema qualified routine name> <SQL parameter declaration list>
<returns clause> <routine characteristics> [ <dispatch clause> ]
<dispatch clause> ::= STATIC DISPATCH
<method specification designator> modified per ISO 9075:1999/Cor.1:2000(E)
<method specification designator> ::=
[ <method name>
<SQL parameter declaration list> [ <returns clause> ] <user-defined type name>
<grant privilege statement> | <grant role statement>
<grant privilege statement> ::=
<privileges> <grantee> [ { <comma> <grantee> }... ]
[ <grantor> ]
<object privileges> <object name>
<action> [ { <comma> <action> }... ]
<action> ::=
<left paren> <privilege column list> <right paren>
| <left paren> <privilege method list> <right paren>
| <left paren> <privilege column list> <right paren> ]
| <left paren> <privilege column list> <right paren> ]
| <left paren> <privilege column list> <right paren> ]
| USAGE
| TRIGGER
| UNDER
| EXECUTE
<privilege method list> ::=
<specific routine designator> [ { <comma> <specific routine designator> }... ]
<object name> ::=
[ <table name>
| <domain name>
| <collation name>
| <character set name>
| <module name>
| <translation name>
| <user-defined type name>
| <specific routine designator>
<grantor> ::= CURRENT_USER | CURRENT_ROLE
<grant role statement> ::=
<role granted> [ { <comma> <role granted> }... ] <grantee> [ { <comma> <grantee> }... ]
[ <grantor> ]
<role name> [ <grantor> ]
<schema routine> | <module routine>
<user-defined cast definition> ::=
<left paren> <source data type> <target data type> <right paren>
<cast function> [ AS ASSIGNMENT ]
<user-defined ordering specification> modified per ISO 9075:1999/Cor.1:2000(E)
<user-defined ordering definition> ::=
<user-defined type name> <ordering form>
<equals ordering form> | <full ordering form>
<relative category> | <map category> | <state category>
<relative function specification>
<transform definition> modified per ISO 9075:1999/Cor.1:2000(E)
<transform definition> ::=
<user-defined type name>
<transform group> ...
<group name> <left paren> <transform element list> <right paren>
<transform element> [ <comma> <transform element> ]
<SQL schema manipulation statement> ::=
<drop schema statement>
| <alter table statement>
| <drop table statement>
| <drop view statement>
| <alter routine statement>
| <drop routine statement>
| <drop user-defined cast statement>
| <revoke statement>
| <drop role statement>
| <alter domain statement>
| <drop domain statement>
| <drop character set statement>
| <drop collation statement>
| <drop translation statement>
| <drop assertion statement>
| <drop trigger statement>
| <alter type statement>
| <drop data type statement>
| <drop user-defined ordering statement>
| <drop transform statement>
| <drop module statement>
<drop behavior> ::= CASCADE | RESTRICT
<table name> <alter table action>
<alter table action> ::=
<add column definition>
| <alter column definition>
| <drop column definition>
| <add table constraint definition>
| <drop table constraint definition>
<column name> <alter column action>
<alter column action> ::=
<set column default clause>
| <drop column default clause>
| <add column scope clause>
| <drop column scope clause>
<drop column default clause> ::= DROP DEFAULT
<constraint name> <drop behavior>
<alter routine statement> ::=
<specific routine designator> <alter routine characteristics> <alter routine behaviour>
<alter routine characteristic> ...
<alter routine characteristic> ::=
<language clause>
| <parameter style clause>
| <SQL-data access indication>
| <null-call clause>
| <dynamic result sets characteristic>
| <external routine name>
<alter routine behaviour> ::= RESTRICT
<specific routine designator> <drop behavior>
<drop user-defined cast statement> ::=
<left paren> <source data type> <target data type> <right paren>
<drop behavior>
<revoke privilege statement> | <revoke role statement>
<revoke privilege statement> ::=
<revoke option extension> ] <privileges> <grantee>
[ { <comma> <grantee> }... ] [ <grantor> ] <drop behavior>
<revoke option extension> ::= GRANT OPTION FOR | HIERARCHY OPTION FOR
<revoke role statement> ::=
<role revoked> [ { <comma> <role revoked> }... ]
<grantee> [ { <comma> <grantee> }... ] [ <grantor> ] <drop behavior>
<domain name> <alter domain action>
<alter domain action> ::=
<set domain default clause>
| <drop domain default clause>
| <add domain constraint definition>
| <drop domain constraint definition>
<drop domain default clause> ::= DROP DEFAULT
<collation name> <drop behavior>
<user-defined type name> <alter type action>
<alter type action> ::=
<add attribute definition>
| <drop attribute definition>
| <add original method specification>
| <add overriding method specification>
| <drop method specification>
<original method specification>
<overriding method specification>
<drop method specification> modified per ISO 9075:1999/Cor.1:2000(E)
<specific method specification designator> RESTRICT
<specific method specification designator> added per ISO 9075:1999/Cor.1:2000(E)
<specific method specification designator> ::=
<specific method name>
| [ <method name> [ <data type list> ]
<user-defined type name> <drop behavior>
<drop user-defined ordering statement> modified per ISO 9075:1999/Cor.1:2000(E)
<drop user-defined ordering statement> ::=
<user-defined type name> <drop behavior>
<drop transform statement> modified per ISO 9075:1999/Cor.1:2000(E)
<drop transform statement> ::=
<transforms to be dropped>
<user-defined type name> <drop behavior>
<SQL data statement> ::=
<open statement>
| <fetch statement>
| <close statement>
| <select statement: single row>
| <free locator statement>
| <hold locator statement>
| <SQL data change statement>
<fetch statement> ::=
<fetch orientation> ] <cursor name> <fetch target list>
<fetch orientation> ::=
<simple value specification>
<simple value specification> ::=
<literal>
| <host parameter name>
| <SQL parameter reference>
| <SQL variable reference>
| <embedded variable name>
<target specification> [ { <comma> <target specification> }... ]
<select statement: single row> ::=
<set quantifier> ] <select list> <select target list> <table expression>
<target specification> [ { <comma> <target specification> }... ]
<free locator statement> ::=
<locator reference> [ { <comma> <locator reference> }... ]
<host parameter name> | <embedded variable name>
<hold locator statement> ::=
<locator reference> [ { <comma> <locator reference> }... ]
<SQL data change statement> ::=
<delete statement: positioned>
| <delete statement: searched>
| <insert statement>
| <update statement: positioned>
| <update statement: searched>
<delete statement: positioned> ::=
<target table> <cursor name>
<target table> modified per ISO 9075:1999/Cor.1:2000(E)
<target table> ::=
<table name>
| [ <left paren> <table name> <right paren>
<delete statement: searched> ::=
<target table> [ <search condition> ]
<insert statement> ::=
<insertion target> <insert columns and source>
<from subquery> | <from constructor> | <from default>
<from subquery> ::=
[ <left paren> <insert column list> <right paren> ] [ <override clause> ] <query expression>
<from constructor> ::=
[ <left paren> <insert column list> <right paren> ] [ <override clause> ]
<contextually typed table value constructor>
<override clause> ::= OVERRIDING USER VALUE | OVERRIDING SYSTEM VALUE
<contextually typed table value constructor> ::=
<contextually typed row value expression list>
<contextually typed row value expression list> ::=
<contextually typed row value expression>
[ { <comma> <contextually typed row value expression> }... ]
<contextually typed row value expression> ::=
<row value special case>
| <contextually typed row value constructor>
<contextually typed row value constructor> ::=
<contextually typed row value constructor element>
| [ <left paren> <contextually typed row value constructor element list> <right paren>
<contextually typed row value constructor element> ::=
<value expression> | <contextually typed value specification>
<contextually typed value specification> ::=
<implicitly typed value specification> | <default specification>
<default specification> ::= DEFAULT
<contextually typed row value constructor element list> ::=
<contextually typed row value constructor element>
[ { <comma> <contextually typed row value constructor element> }... ]
<from default> ::= DEFAULT VALUES
<update statement: positioned> ::=
<target table> <set clause list> <cursor name>
<set clause> [ { <comma> <set clause> }... ]
<set clause> ::=
<update target> <equals operator> <update source>
| <mutated set clause> <equals operator> <update source>
<update target> modified per ISO 9075:1999/Cor.1:2000(E)
<update target> ::=
<object column>
| <object column> <left bracket or trigraph> <simple value specification> <right bracket or trigraph>
<value expression> | <contextually typed value specification>
<mutated target> <period> <method name>
<object column> | <mutated set clause>
<update statement: searched> ::=
<target table> <set clause list> [ <search condition> ]
<SQL control statement> ::=
<call statement>
| <return statement>
| <assignment statement>
| <compound statement>
| <case statement>
| <if statement>
| <iterate statement>
| <leave statement>
| <loop statement>
| <while statement>
| <repeat statement>
| <for statement>
<SQL transaction statement> ::=
<start transaction statement>
| <set transaction statement>
| <set constraints mode statement>
| <savepoint statement>
| <release savepoint statement>
| <commit statement>
| <rollback statement>
<start transaction statement> ::=
<transaction mode> [ { <comma> <transaction mode> }...]
<isolation level> | <transaction access mode> | <diagnostics size>
<level of isolation> ::=
READ UNCOMMITTED
| READ COMMITTED
| REPEATABLE READ
| SERIALIZABLE
<transaction access mode> ::= READ ONLY | READ WRITE
<transaction characteristics> ::=
<transaction mode> [ { <comma> <transaction mode> }... ]
<set constraints mode statement> ::=
<constraint name list> { DEFERRED | IMMEDIATE }
<constraint name> [ { <comma> <constraint name> }... ]
<savepoint specifier> modified per ISO 9075:1999/Cor.1:2000(E)
<simple target specification> ::=
<host parameter specification>
| <SQL parameter reference>
| <column reference>
| <SQL variable reference>
| <embedded variable name>
<commit statement> ::= COMMIT [ WORK ] [ AND [ NO ] CHAIN ]
<connect statement> | <set connection statement> | <disconnect statement>
<connection target> ::=
<SQL-server name> [ <connection name> ] [ <connection user name> ]
| DEFAULT
<connection object> | ALL | CURRENT
<SQL session statement> ::=
<set session user identifier statement>
| <set role statement>
| <set local time zone statement>
| <set session characteristics statement>
| <set catalog statement>
| <set schema statement>
| <set names statement>
| <set path statement>
| <set transform group statement>
<set session user identifier statement> ::=
<value specification>
<interval value expression> | LOCAL
<set session characteristics statement> ::=
<session characteristic list>
<session characteristic> [ { <comma> <session characteristic> }... ]
<get diagnostics statement> | <signal statement> | <resignal statement>
<statement information> | <condition information>
<statement information> ::=
<statement information item> [ { <comma> <statement information item> }... ]
<statement information item> ::=
<simple target specification> <equals operator> <statement information item name>
<statement information item name> ::=
NUMBER
| MORE
| COMMAND_FUNCTION
| COMMAND_FUNCTION_CODE
| DYNAMIC_FUNCTION
| DYNAMIC_FUNCTION_CODE
| ROW_COUNT
| TRANSACTIONS_COMMITTED
| TRANSACTIONS_ROLLED_BACK
| TRANSACTION_ACTIVE
<condition information> ::=
<condition number>
<condition information item> [ { <comma> <condition information item> }... ]
<condition information item> ::=
<simple target specification> <equals operator> <condition information item name>
<condition information item name> ::=
CATALOG_NAME
| CLASS_ORIGIN
| COLUMN_NAME
| CONDITION_IDENTIFIER
| CONDITION_NUMBER
| CONNECTION_NAME
| CONSTRAINT_CATALOG
| CONSTRAINT_NAME
| CONSTRAINT_SCHEMA
| CURSOR_NAME
| MESSAGE_LENGTH
| MESSAGE_OCTET_LENGTH
| MESSAGE_TEXT
| PARAMETER_MODE
| PARAMETER_NAME
| PARAMETER_ORDINAL_POSITION
| RETURNED_SQLSTATE
| ROUTINE_CATALOG
| ROUTINE_NAME
| ROUTINE_SCHEMA
| SCHEMA_NAME
| SERVER_NAME
| SPECIFIC_NAME
| SUBCLASS_ORIGIN
| TABLE_NAME
| TRIGGER_CATALOG
| TRIGGER_NAME
| TRIGGER_SCHEMA
<dereference operation> ::=
<reference value expression> <dereference operator> <attribute name>
<method reference> ::=
<value expression primary> <dereference operator> <method name> <SQL argument list>
<new invocation> modified per ISO 9075:1999/Cor.1:2000(E)
<method invocation> | <routine invocation>
<nondelimiter token> | <delimiter token>
<nondelimiter token> ::=
<regular identifier>
| <key word>
| <unsigned numeric literal>
| <national character string literal>
| <bit string literal>
| <hex string literal>
| <large object length token>
| <multiplier>
<reserved word> | <non-reserved word>
<reserved word> modified per ISO 9075:1999/Cor.1:2000(E)
<reserved word> ::=
ABSOLUTE | ACTION | ADD | AFTER | ALL | ALLOCATE | ALTER | AND | ANY | ARE
| ARRAY | AS | ASC | ASSERTION | AT | AUTHORIZATION
| BEFORE | BEGIN | BETWEEN | BINARY | BIT | BLOB | BOOLEAN | BOTH
| BREADTH | BY
| CALL | CASCADE | CASCADED | CASE | CAST | CATALOG | CHAR | CHARACTER
| CHECK | CLOB | CLOSE | COLLATE | COLLATION | COLUMN | COMMIT
| CONDITION | CONNECT | CONNECTION | CONSTRAINT | CONSTRAINTS
| CONSTRUCTOR | CONTINUE | CORRESPONDING | CREATE | CROSS | CUBE
| CURRENT | CURRENT_DATE | CURRENT_DEFAULT_TRANSFORM_GROUP
| CURRENT_TRANSFORM_GROUP_FOR_TYPE | CURRENT_PATH | CURRENT_ROLE
| CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | CURSOR | CYCLE
| DATA | DATE | DAY | DEALLOCATE | DEC | DECIMAL | DECLARE | DEFAULT
| DEFERRABLE | DEFERRED | DELETE | DEPTH | DEREF | DESC
| DESCRIBE | DESCRIPTOR | DETERMINISTIC
| DIAGNOSTICS | DISCONNECT | DISTINCT | DO | DOMAIN | DOUBLE
| DROP | DYNAMIC
| EACH | ELSE | ELSEIF | END | END-EXEC | EQUALS | ESCAPE | EXCEPT
| EXCEPTION | EXEC | EXECUTE | EXISTS | EXIT | EXTERNAL
| FALSE | FETCH | FIRST | FLOAT | FOR | FOREIGN | FOUND | FROM | FREE
| FULL | FUNCTION
| GENERAL | GET | GLOBAL | GO | GOTO | GRANT | GROUP | GROUPING
| HANDLE | HAVING | HOLD | HOUR
| IDENTITY | IF | IMMEDIATE | IN | INDICATOR
| INITIALLY | INNER | INOUT | INPUT | INSERT | INT | INTEGER
| INTERSECT | INTERVAL | INTO | IS | ISOLATION
| JOIN
| KEY
| LANGUAGE | LARGE | LAST | LATERAL | LEADING | LEAVE | LEFT
| LEVEL | LIKE | LOCAL | LOCALTIME | LOCALTIMESTAMP | LOCATOR | LOOP
| MAP | MATCH | METHOD | MINUTE | MODIFIES | MODULE | MONTH
| NAMES | NATIONAL | NATURAL | NCHAR | NCLOB | NESTING | NEW | NEXT
| NO | NONE | NOT | NULL | NUMERIC
| OBJECT | OF | OLD | ON | ONLY | OPEN | OPTION
| OR | ORDER | ORDINALITY | OUT | OUTER | OUTPUT | OVERLAPS
| PAD | PARAMETER | PARTIAL | PATH | PRECISION
| PREPARE | PRESERVE | PRIMARY | PRIOR | PRIVILEGES | PROCEDURE | PUBLIC
| READ | READS | REAL | RECURSIVE | REDO | REF | REFERENCES | REFERENCING
| RELATIVE | RELEASE | REPEAT | RESIGNAL | RESTRICT | RESULT | RETURN
| RETURNS | REVOKE | RIGHT | ROLE | ROLLBACK | ROLLUP | ROUTINE
| ROW | ROWS
| SAVEPOINT | SCHEMA | SCROLL | SEARCH | SECOND | SECTION | SELECT
| SESSION | SESSION_USER | SET | SETS | SIGNAL | SIMILAR | SIZE
| SMALLINT | SOME | SPACE | SPECIFIC | SPECIFICTYPE | SQL | SQLEXCEPTION
| SQLSTATE | SQLWARNING | START | STATE | STATIC | SYSTEM_USER
| TABLE | TEMPORARY | THEN | TIME | TIMESTAMP
| TIMEZONE_HOUR | TIMEZONE_MINUTE | TO | TRAILING | TRANSACTION
| TRANSLATION | TREAT | TRIGGER | TRUE
| UNDER | UNDO | UNION | UNIQUE | UNKNOWN | UNNEST | UNTIL | UPDATE
| USAGE | USER | USING
| VALUE | VALUES | VARCHAR | VARYING | VIEW
| WHEN | WHENEVER | WHERE | WHILE | WITH | WITHOUT | WORK | WRITE
| YEAR
| ZONE
<non-reserved word> modified per ISO 9075:1999/Cor.1:2000(E)
<non-reserved word> ::=
ABS | ADA | ADMIN | ASENSITIVE | ASSIGNMENT | ASYMMETRIC | ATOMIC
| ATTRIBUTE | AVG
| BIT_LENGTH
| C | CALLED | CARDINALITY | CATALOG_NAME | CHAIN | CHAR_LENGTH
| CHARACTERISTICS | CHARACTER_LENGTH | CHARACTER_SET_CATALOG
| CHARACTER_SET_NAME | CHARACTER_SET_SCHEMA | CHECKED | CLASS_ORIGIN
| COALESCE | COBOL | COLLATION_CATALOG | COLLATION_NAME | COLLATION_SCHEMA
| COLUMN_NAME | COMMAND_FUNCTION | COMMAND_FUNCTION_CODE | COMMITTED
| CONDITION_IDENTIFIER | CONDITION_NUMBER | CONNECTION_NAME
| CONSTRAINT_CATALOG | CONSTRAINT_NAME | CONSTRAINT_SCHEMA | CONTAINS
| CONVERT | COUNT | CURSOR_NAME
| DATETIME_INTERVAL_CODE | DATETIME_INTERVAL_PRECISION | DEFINED
| DEFINER | DEGREE | DERIVED | DISPATCH
| EVERY | EXTRACT
| FINAL | FORTRAN
| G | GENERATED | GRANTED
| HIERARCHY
| IMPLEMENTATION | INSENSITIVE | INSTANCE | INSTANTIABLE | INVOKER
| K | KEY_MEMBER | KEY_TYPE
| LENGTH | LOWER
| M | MAX | MIN | MESSAGE_LENGTH | MESSAGE_OCTET_LENGTH | MESSAGE_TEXT
| MOD | MORE | MUMPS
| NAME | NULLABLE | NUMBER | NULLIF
| OCTET_LENGTH | ORDERING | OPTIONS | OVERLAY | OVERRIDING
| PASCAL | PARAMETER_MODE | PARAMETER_NAME
| PARAMETER_ORDINAL_POSITION | PARAMETER_SPECIFIC_CATALOG
| PARAMETER_SPECIFIC_NAME | PARAMETER_SPECIFIC_SCHEMA | PLI | POSITION
| REPEATABLE | RETURNED_CARDINALITY | RETURNED_LENGTH
| RETURNED_OCTET_LENGTH | RETURNED_SQLSTATE | ROUTINE_CATALOG
| ROUTINE_NAME | ROUTINE_SCHEMA | ROW_COUNT
| SCALE | SCHEMA_NAME | SCOPE | SECURITY | SELF | SENSITIVE | SERIALIZABLE
| SERVER_NAME | SIMPLE | SOURCE | SPECIFIC_NAME | STATEMENT | STRUCTURE
| STYLE | SUBCLASS_ORIGIN | SUBSTRING | SUM | SYMMETRIC | SYSTEM
| TABLE_NAME | TOP_LEVEL_COUNT | TRANSACTIONS_COMMITTED
| TRANSACTIONS_ROLLED_BACK | TRANSACTION_ACTIVE | TRANSFORM
| TRANSFORMS | TRANSLATE | TRIGGER_CATALOG | TRIGGER_SCHEMA
| TRIGGER_NAME | TRIM | TYPE
| UNCOMMITTED | UNNAMED | UPPER
<delimiter token> ::=
<character string literal>
| <date string>
| <time string>
| <timestamp string>
| <interval string>
| <delimited identifier>
| <SQL special character>
| <not equals operator>
| <greater than or equals operator>
| <less than or equals operator>
| <concatenation operator>
| <right arrow>
| <left bracket trigraph>
| <right bracket trigraph>
| <double colon>
| <double period>
<CLI routine name> <CLI parameter list> [ <CLI returns clause> ]
<CLI name prefix> <CLI generic name>
<CLI by-reference prefix> | <CLI by-value prefix>
<CLI by-reference prefix> ::= SQLR
<CLI generic name> ::=
<implementation-defined CLI generic name>
<implementation-defined CLI generic name> ::= !! (See the Syntax Rules)
<CLI parameter list> ::=
<left paren> <CLI parameter declaration> [ { <comma> <CLI parameter declaration> }... ] <right paren>
<CLI parameter declaration> ::=
<CLI parameter name> <CLI parameter mode> <CLI parameter data type>
<CLI parameter name> ::= !! (See the individual CLI routine definitions)
<CLI parameter mode> ::= IN | OUT | DEFIN | DEFOUT | DEF
<CLI parameter data type> ::=
<left paren> <length> <right paren>
<CLI returns clause> ::= RETURNS SMALLINT
<assignment statement> ::=
<assignment target> <equals operator> <assignment source>
<target specification> | <modified field reference> | <mutator reference>
<modified field target> <period> <field name>
<modified field target> ::=
<target specification> | <left paren> <target specification> <right paren> | <modified field reference>
<mutated target specification> <period> <method name>
<mutated target specification> ::=
<target specification> | <left paren> <target specification> <right paren> | <mutator reference>
<value expression> | <contextually typed source>
<contextually typed source> ::=
<implicitly typed value specification> | <contextually typed row value expression>
<compound statement> ::=
[ <beginning label> <colon> ] <local declaration list> ] [ <local cursor declaration list> ] [ <local handler declaration list> ]
[ <SQL statement list> ] <ending label> ]
<terminated local declaration> ...
<local declaration> <semicolon>
<SQL variable declaration> | <condition declaration>
<SQL variable declaration> ::=
<SQL variable name list> <data type> [ <default clause> ]
<SQL variable name list> ::=
<SQL variable name> [ { <comma> <SQL variable name> }... ]
<condition declaration> ::=
<condition name> <sqlstate value> ]
<terminated local cursor declaration> ...
<terminated local handler declaration> ...
<handler declaration> <semicolon>
<handler declaration> ::=
<handler type> <condition value list> <handler action>
<handler type> ::= CONTINUE | EXIT | UNDO
<condition value> [ { <comma> <condition value> }... ]
<condition value> ::=
<sqlstate value> | <condition name> | SQLEXCEPTION | SQLWARNING | NOT FOUND
<terminated SQL statement> ...
<SQL procedure statement> <semicolon>
<simple case statement> | <searched case statement>
<simple case statement> ::=
<simple case operand 1> <simple case statement when clause> ... [ <case statement else clause> ] END CASE
<simple case statement when clause> ::=
<simple case operand 2> <SQL statement list>
<searched case statement> ::=
<searched case statement when clause> ... [ <case statement else clause> ] END CASE
<searched case statement when clause> ::=
<search condition> <SQL statement list>
<if statement> ::=
<search condition> <if statement then clause>
[ <if statement elseif clause> ... ] [ <if statement else clause> ]
END IF
<search condition> <SQL statement list>
<loop statement> ::=
[ <beginning label> <colon> ] <SQL statement list> <ending label> ]
<while statement> ::=
[ <beginning label> <colon> ] <search condition> <SQL statement list> <ending label> ]
<repeat statement> ::=
[ <beginning label> <colon> ] <SQL statement list> <search condition> <ending label> ]
<for statement> ::=
[ <beginning label> <colon> ] <for loop variable name> <cursor name> [ <cursor sensitivity> ] <cursor specification>
<SQL statement list> <ending label> ]
<signal value> [ <set signal information> ]
<condition name> | <sqlstate value>
<signal information item list>
<signal information item list> ::=
<signal information item> [ { <comma> <signal information item> }... ]
<signal information item> ::=
<condition information item name> <equals operator> <simple value specification>
<signal value> ] [ <set signal information> ]
<SQL-server module definition> ::=
<SQL-server module name> [ <SQL-server module character set specification> ]
[ <SQL-server module schema clause> ] [ <SQL-server module path specification> ]
[ <temporary table declaration> ]
<SQL-server module contents> ...
END MODULE
<SQL-invoked routine> <semicolon>
<module procedure> | <module function>
<SQL-server module name> <drop behavior>
This definition of <triggered SQL statement> is from 9075-4 (SQL/PSM) and is documented with: NOTE 13 – The preceding production defining <triggered SQL statement> completely supersedes the definition in ISO/IEC 9075-2.
Much, if not all, of the following material comes from ISO/IEC 9075-5:1999, SQL/Bindings.
<SQL dynamic statement> ::=
<system descriptor statement>
| <prepare statement>
| <deallocate prepared statement>
| <describe statement>
| <execute statement>
| <execute immediate statement>
| <SQL dynamic data statement>
<system descriptor statement> ::=
<allocate descriptor statement>
| <deallocate descriptor statement>
| <set descriptor statement>
| <get descriptor statement>
<allocate descriptor statement> ::=
<descriptor name> [ <occurrences> ]
<scope option> ] <simple value specification>
<scope option> ::= GLOBAL | LOCAL
<host identifier> ::=
<Ada host identifier>
| <C host identifier>
| <COBOL host identifier>
| <Fortran host identifier>
| <MUMPS host identifier>
| <Pascal host identifier>
| <PL/I host identifier>
<Ada host identifier> ::= !! (See the Syntax Rules.)
<C host identifier> ::= !! (See the Syntax Rules.)
<COBOL host identifier> ::= !! (See the Syntax Rules.)
<Fortran host identifier> ::= !! (See the Syntax Rules.)
<MUMPS host identifier> ::= !! (See the Syntax Rules.)
<Pascal host identifier> ::= !! (See the Syntax Rules.)
<PL/I host identifier> ::= !! (See the Syntax Rules.)
<descriptor name> <set descriptor information>
<set descriptor information> ::=
<set header information> [ { <comma> <set header information> }... ]
| <item number> <set item information> [ { <comma> <set item information> }... ]
<set header information> ::=
<header item name> <equals operator> <simple value specification 1>
<header item name> ::=
COUNT | KEY_TYPE | DYNAMIC_FUNCTION | DYNAMIC_FUNCTION_CODE
| TOP_LEVEL_COUNT
<set item information> ::=
<descriptor item name> <equals operator> <simple value specification 2>
<descriptor item name> ::=
CARDINALITY
| CHARACTER_SET_CATALOG
| CHARACTER_SET_NAME
| CHARACTER_SET_SCHEMA
| COLLATION_CATALOG
| COLLATION_NAME
| COLLATION_SCHEMA
| DATA
| DATETIME_INTERVAL_CODE
| DATETIME_INTERVAL_PRECISION
| DEGREE
| INDICATOR
| KEY_MEMBER
| LENGTH
| LEVEL
| NAME
| NULLABLE
| OCTET_LENGTH
| PARAMETER_MODE
| PARAMETER_ORDINAL_POSITION
| PARAMETER_SPECIFIC_CATALOG
| PARAMETER_SPECIFIC_NAME
| PARAMETER_SPECIFIC_SCHEMA
| PRECISION
| RETURNED_CARDINALITY
| RETURNED_LENGTH
| RETURNED_OCTET_LENGTH
| SCALE
| SCOPE_CATALOG
| SCOPE_NAME
| SCOPE_SCHEMA
| TYPE
| UNNAMED
| USER_DEFINED_TYPE_CATALOG
| USER_DEFINED_TYPE_NAME
| USER_DEFINED_TYPE_SCHEMA
<get descriptor statement> ::=
<descriptor name> <get descriptor information>
<get descriptor information> ::=
<get header information> [ { <comma> <get header information> }... ]
| <item number> <get item information> [ { <comma> <get item information> }... ]
<get header information> ::=
<simple target specification 1> <equals operator> <header item name>
<get item information> ::=
<simple target specification 2> <equals operator> <descriptor item name>
<prepare statement> ::=
<SQL statement name> <SQL statement variable>
<SQL statement name> ::=
<statement name>
| <extended statement name>
<scope option> ] <simple value specification>
<describe input statement> | <describe output statement>
<describe input statement> ::=
<SQL statement name> <using descriptor> [ <nesting option> ]
<nesting option> ::= WITH NESTING | WITHOUT NESTING
<describe output statement> ::=
<described object> <using descriptor> [ <nesting option> ]
<described object> ::=
<SQL statement name> | <extended cursor name> STRUCTURE
<scope option> ] <simple value specification>
<execute statement> ::=
<SQL statement name> [ <result using clause> ] [ <parameter using clause> ]
<into arguments> | <into descriptor>
<into argument> [ { <comma> <into argument> }... ]
<embedded variable name> [ <indicator variable> ]
<using arguments> | <using input descriptor>
<using argument> [ { <comma> <using argument> }... ]
<SQL dynamic data statement> ::=
<allocate cursor statement>
| <dynamic open statement>
| <dynamic fetch statement>
| <dynamic close statement>
| <dynamic delete statement: positioned>
| <dynamic update statement: positioned>
<extended cursor name> <cursor intent>
<statement cursor> | <result set cursor>
<statement cursor> ::=
[ <cursor sensitivity> ] [ <extended statement name>
<result set cursor> ::=
<specific routine designator>
<dynamic open statement> ::=
<dynamic cursor name> [ <input using clause> ]
<cursor name> | <extended cursor name>
<dynamic fetch statement> ::=
<fetch orientation> ] <dynamic cursor name> <output using clause>
<dynamic delete statement: positioned> ::=
<target table> <dynamic cursor name>
<dynamic update statement: positioned> ::=
<target table> <set clause list> <dynamic cursor name>
Note that <double period> must be a pair of period characters with no intervening space, not a pair of period symbols separated by arbitrary white space. Normally, the lexical analyzer would return <double period> as a symbol.
<directly executable statement> <semicolon>
<directly executable statement> ::=
<direct SQL data statement>
| <SQL schema statement>
| <SQL transaction statement>
| <SQL connection statement>
| <SQL session statement>
| <direct implementation-defined statement>
<direct SQL data statement> ::=
<delete statement: searched>
| <direct select statement: multiple rows>
| <insert statement>
| <update statement: searched>
| <temporary table declaration>
<query expression> [ <order by clause> ]
<character set name characteristic>
<transform group characteristic>
<transform group characteristic> ::=
<value specification>
| <user-defined type> <value specification>
<direct implementation-defined statement> ::= !! (See the Syntax Rules)
<embedded SQL declare section> ::=
<embedded SQL begin declare>
[ <embedded character set declaration> ]
[ <host variable definition> ... ]
<embedded SQL end declare>
| <embedded SQL MUMPS declare>
<embedded SQL begin declare> ::=
<SQL prefix> <SQL terminator> ]
<embedded character set declaration> ::=
<character set specification>
<host variable definition> ::=
<Ada variable definition>
| <C variable definition>
| <COBOL variable definition>
| <Fortran variable definition>
| <MUMPS variable definition>
| <Pascal variable definition>
| <PL/I variable definition>
<Ada variable definition> ::=
<Ada host identifier> [ { <comma> <Ada host identifier> }... ] <colon>
<Ada type specification> [ <Ada initial value> ]
<Ada type specification> ::=
<Ada qualified type specification>
| <Ada unqualified type specification>
| <Ada derived type specification>
<Ada qualified type specification> ::=
<period> <character set specification> ]
<left paren> <double period> <length> <right paren>
| <period> <left paren> <double period> <length> <right paren>
| <period> <period> <period> <period> <period> <period> <period> INDICATOR_TYPE
<Ada unqualified type specification> ::=
<left paren> <double period> <length> <right paren>
| <left paren> <double period> <length> <right paren>
| SMALLINT
| INT
| REAL
| DOUBLE_PRECISION
| BOOLEAN
| SQLSTATE_TYPE
| INDICATOR_TYPE
<Ada derived type specification> ::=
<Ada CLOB variable>
| <Ada BLOB variable>
| <Ada user-defined type variable>
| <Ada CLOB locator variable>
| <Ada BLOB locator variable>
| <Ada user-defined type locator variable>
| <Ada array locator variable>
| <Ada REF variable>
<Ada CLOB variable> ::=
<left paren> <large object length> <right paren>
[ <character set specification> ]
<Ada BLOB variable> ::=
<left paren> <large object length> <right paren>
<Ada user-defined type variable> ::=
<user-defined type> <predefined type>
<Ada CLOB locator variable> ::=
SQL TYPE IS CLOB AS LOCATOR
<Ada BLOB locator variable> ::=
SQL TYPE IS BLOB AS LOCATOR
<Ada user-defined type locator variable> ::=
<user-defined type name> AS LOCATOR
<Ada array locator variable> ::=
<collection type> AS LOCATOR
<Ada REF variable> ::=
<reference type>
<Ada initial value> ::=
<Ada assignment operator> <character representation> ...
<C variable definition> ::=
[ <C storage class> ] [ <C class modifier> ] <C variable specification> <semicolon>
<C storage class> ::= auto | extern | static
<C class modifier> ::= const | volatile
<C numeric variable> | <C character variable> | <C derived variable>
<C numeric variable> ::=
{ <C host identifier> [ <C initial value> ]
[ { <comma> <C host identifier> [ <C initial value> ] }... ]
<C initial value> ::=
<equals operator> <character representation> ...
<C character variable> ::=
<C character type> [ <character set specification> ]
<C host identifier> <C array specification> [ <C initial value> ]
[ { <comma> <C host identifier> <C array specification> [ <C initial value> ] }... ]
<C character type> ::= char | unsigned char | unsigned short
<left bracket> <length> <right bracket>
<C derived variable> ::=
<C VARCHAR variable>
| <C NCHAR variable>
| <C NCHAR VARYING variable>
| <C CLOB variable>
| <C NCLOB variable>
| <C BLOB variable>
| <C bit variable>
| <C user-defined type variable>
| <C CLOB locator variable>
| <C BLOB locator variable>
| <C array locator variable>
| <C user-defined type locator variable>
| <C REF variable>
<C VARCHAR variable> ::=
<character set specification> ]
<C host identifier> <C array specification> [ <C initial value> ]
[ { <comma> <C host identifier> <C array specification> [ <C initial value> ] }... ]
<C NCHAR variable> ::=
<character set specification> ]
<C host identifier> <C array specification> [ <C initial value> ]
[ { <comma> <C host identifier> <C array specification> [ <C initial value> ] } ... ]
<C NCHAR VARYING variable> ::=
<character set specification> ]
<C host identifier> <C array specification> [ <C initial value> ]
[ { <comma> <C host identifier> <C array specification> [ <C initial value> ] } ... ]
<C CLOB variable> ::=
<left paren> <large object length> <right paren>
[ <character set specification> ]
<C host identifier> [ <C initial value> ] [ { <comma> <C host identifier> [ <C initial value> ] }... ]
<C NCLOB variable> ::=
<left paren> <large object length> <right paren>
[ <character set specification> ]
<C host identifier> [ <C initial value> ] [ { <comma> <C host identifier> [ <C initial value> ] }... ]
<C BLOB variable> ::=
<left paren> <large object length> <right paren>
<C host identifier> [ <C initial value> ] [ { <comma> <C host identifier> [ <C initial value> ] } ... ]
<C bit variable> ::=
<C host identifier> <C array specification> [ <C initial value> ]
[ { <comma> <C host identifier> <C array specification> [ <C initial value> ] }... ]
<C user-defined type variable> ::=
<user-defined type> <predefined type>
<C host identifier> [ <C initial value> ] [ { <comma> <C host identifier> [ <C initial value> ] } ... ]
<C CLOB locator variable> ::=
<C host identifier> [ <C initial value> ] [ { <comma> <C host identifier> [ <C initial value> ] } ... ]
<C BLOB locator variable> ::=
<C host identifier> [ <C initial value> ] [ { <comma> <C host identifier> [ <C initial value> ] } ... ]
<C array locator variable> ::=
<collection type> <C host identifier> [ <C initial value> ] [ { <comma> <C host identifier> [ <C initial value> ] } ... ]
<C user-defined type locator variable> ::=
<user-defined type> <C host identifier> [ <C initial value> ] [ { <comma> <C host identifier> [ <C initial value> ] }... ]
<C REF variable> ::=
<reference type>
<COBOL variable definition> ::=
{01|77} <COBOL host identifier> <COBOL type specification>
[ <character representation> ... ] <period>
<COBOL type specification> ::=
<COBOL character type>
| <COBOL national character type>
| <COBOL bit type>
| <COBOL numeric type>
| <COBOL integer type>
| <COBOL derived type specification>
<COBOL character type> ::=
[ <character set specification> ]
{ <left paren> <length> <right paren> ] }...
<COBOL national character type> ::=
[ <character set specification> ]
{ <left paren> <length> <right paren> ] }...
<COBOL bit type> ::=
{ <left paren> <length> <right paren> ] }...
USAGE [ IS ] BIT
<COBOL numeric type> ::=
{ <COBOL nines specification>
[ USAGE [ IS ] ] DISPLAY SIGN LEADING SEPARATE
<COBOL nines> [ <COBOL nines> ] ] | <COBOL nines>
<left paren> <length> <right paren> ] }...
<COBOL binary integer> ::=
{ <COBOL nines> [ USAGE [ IS ] ] BINARY
<COBOL derived type specification> ::=
<COBOL CLOB variable>
| <COBOL NCLOB variable>
| <COBOL BLOB variable>
| <COBOL user-defined type variable>
| <COBOL CLOB locator variable>
| <COBOL BLOB locator variable>
| <COBOL array locator variable>
| <COBOL user-defined type locator variable>
| <COBOL REF variable>
<COBOL CLOB variable> ::=
[ <left paren> <large object length> <right paren>
[ <character set specification> ]
<COBOL NCLOB variable> ::=
[ <left paren> <large object length> <right paren>
[ <character set specification> ]
<COBOL BLOB variable> ::=
[ <left paren> <large object length> <right paren>
<COBOL user-defined type variable> ::=
[ <user-defined type> <predefined type>
<COBOL CLOB locator variable> ::=
[ USAGE [ IS ] ] SQL TYPE IS CLOB AS LOCATOR
<COBOL BLOB locator variable> ::=
[ USAGE [ IS ] ] SQL TYPE IS BLOB AS LOCATOR
<COBOL array locator variable> ::=
[ <collection type> AS LOCATOR
<COBOL user-defined type locator variable> ::=
[ <user-defined type name> AS LOCATOR
<COBOL REF variable> ::=
[ <reference type>
<Fortran variable definition> ::=
<Fortran type specification> <Fortran host identifier> [ { <comma> <Fortran host identifier> }... ]
The standard documents 'CHARACTER KIND = n' but there is no explanation of the italic 'n' that is used. Presumably, it is an integer literal, hence <unsigned integer>.
<Fortran type specification> ::=
<asterisk> <length> ] [ <character set specification> ]
| <equals operator> <unsigned integer> [ <asterisk> <length> ] [ <character set specification> ]
| <asterisk> <length> ]
| <Fortran derived type specification>
<Fortran derived type specification> ::=
<Fortran CLOB variable>
| <Fortran BLOB variable>
| <Fortran user-defined type variable>
| <Fortran CLOB locator variable>
| <Fortran BLOB locator variable>
| <Fortran user-defined type locator variable>
| <Fortran array locator variable>
| <Fortran REF variable>
<Fortran CLOB variable> ::=
<left paren> <large object length> <right paren>
[ <character set specification> ]
<Fortran BLOB variable> ::=
<left paren> <large object length> <right paren>
<Fortran user-defined type variable> ::=
<user-defined type> <predefined type>
<Fortran CLOB locator variable> ::=
SQL TYPE IS CLOB AS LOCATOR
<Fortran BLOB locator variable> ::=
SQL TYPE IS BLOB AS LOCATOR
<Fortran user-defined type locator variable> ::=
<user-defined type name> AS LOCATOR
<Fortran array locator variable> ::=
<collection type> AS LOCATOR
<Fortran REF variable> ::=
<reference type>
<MUMPS variable definition> ::=
<MUMPS numeric variable> <semicolon>
| <MUMPS character variable> <semicolon>
| <MUMPS derived type specification> <semicolon>
<MUMPS numeric variable> ::=
<MUMPS type specification> <MUMPS host identifier>
[ { <comma> <MUMPS host identifier> }... ]
<MUMPS type specification> ::=
<left paren> <precision> [ <comma> <scale> ] <right paren> ]
| REAL
<MUMPS character variable> ::=
<MUMPS host identifier> <MUMPS length specification>
[ { <comma> <MUMPS host identifier> <MUMPS length specification> }... ]
<MUMPS length specification> ::=
<left paren> <length> <right paren>
<MUMPS derived type specification> ::=
<MUMPS CLOB variable>
| <MUMPS BLOB variable>
| <MUMPS user-defined type variable>
| <MUMPS CLOB locator variable>
| <MUMPS BLOB locator variable>
| <MUMPS user-defined type locator variable>
| <MUMPS array locator variable>
| <MUMPS REF variable>
<MUMPS CLOB variable> ::=
<left paren> <large object length> <right paren>
[ <character set specification> ]
<MUMPS BLOB variable> ::=
<left paren> <large object length> <right paren>
<MUMPS user-defined type variable> ::=
<user-defined type> <predefined type>
<MUMPS CLOB locator variable> ::= SQL TYPE IS CLOB AS LOCATOR
<MUMPS BLOB locator variable> ::= SQL TYPE IS BLOB AS LOCATOR
<MUMPS user-defined type locator variable> ::=
<user-defined type name> AS LOCATOR
<MUMPS array locator variable> ::=
<collection type> AS LOCATOR
<Pascal variable definition> ::=
<Pascal host identifier> [ { <comma> <Pascal host identifier> }... ] <colon>
<Pascal type specification> <semicolon>
<Pascal type specification> ::=
<left bracket> <double period> <length> <right bracket>
<character set specification> ]
| <left bracket> <double period> <length> <right bracket> <character set specification> ]
| <Pascal derived type specification>
<Pascal derived type specification> ::=
<Pascal CLOB variable>
| <Pascal BLOB variable>
| <Pascal user-defined type variable>
| <Pascal CLOB locator variable>
| <Pascal BLOB locator variable>
| <Pascal user-defined type locator variable>
| <Pascal array locator variable>
| <Pascal REF variable>
<Pascal CLOB variable> ::=
<left paren> <large object length> <right paren>
[ <character set specification> ]
<Pascal BLOB variable> ::=
<left paren> <large object length> <right paren>
<Pascal user-defined type variable> ::=
<user-defined type> <predefined type>
<Pascal CLOB locator variable> ::= SQL TYPE IS CLOB AS LOCATOR
<Pascal BLOB locator variable> ::= SQL TYPE IS BLOB AS LOCATOR
<Pascal user-defined type locator variable> ::=
<user-defined type name> AS LOCATOR
<Pascal array locator variable> ::=
<collection type> AS LOCATOR
<PL/I variable definition> ::=
{DCL | <PL/I host identifier> | <left paren> <PL/I host identifier> [ { <comma> <PL/I host identifier> }... ] <right paren> }
<PL/I type specification> [ <character representation> ... ] <semicolon>
<PL/I type specification> ::=
{ <left paren> <length> <right paren>
[ <character set specification> ]
| <left paren> <length> <right paren>
| <PL/I type fixed decimal> <left paren> <precision> [ <comma> <scale> ] <right paren>
| <PL/I type fixed binary> [ <left paren> <precision> <right paren> ]
| <PL/I type float binary> <left paren> <precision> <right paren>
| <PL/I derived type specification>
<PL/I type fixed decimal> ::=
{ DEC | DECIMAL } FIXED
| FIXED { DEC | DECIMAL }
<PL/I type fixed binary> ::=
{ BIN | BINARY } FIXED
| FIXED { BIN | BINARY }
<PL/I type float binary> ::=
{ BIN | BINARY } FLOAT
| FLOAT { BIN | BINARY }
<PL/I derived type specification> ::=
<PL/I CLOB variable>
| <PL/I BLOB variable>
| <PL/I user-defined type variable>
| <PL/I CLOB locator variable>
| <PL/I BLOB locator variable>
| <PL/I user-defined type locator variable>
| <PL/I array locator variable>
| <PL/I REF variable>
<PL/I CLOB variable> ::=
<left paren> <large object length> <right paren>
[ <character set specification> ]
<PL/I BLOB variable> ::=
<left paren> <large object length> <right paren>
<PL/I user-defined type variable> ::=
<user-defined type> <predefined type>
<PL/I CLOB locator variable> ::= SQL TYPE IS CLOB AS LOCATOR
<PL/I BLOB locator variable> ::= SQL TYPE IS BLOB AS LOCATOR
<PL/I user-defined type locator variable> ::=
<user-defined type name> AS LOCATOR
<embedded SQL end declare> ::=
<SQL prefix> <SQL terminator> ]
<embedded SQL MUMPS declare> ::=
<SQL prefix> <embedded character set declaration> ] [ <host variable definition> ... ]
<SQL terminator>
<embedded SQL host program> ::=
<embedded SQL Ada program>
| <embedded SQL C program>
| <embedded SQL COBOL program>
| <embedded SQL Fortran program>
| <embedded SQL MUMPS program>
| <embedded SQL Pascal program>
| <embedded SQL PL/I program>
<embedded SQL Ada program> ::= !! (See the Syntax Rules.)
<embedded SQL C program> ::= !! (See the Syntax Rules.)
<embedded SQL COBOL program> ::= !! (See the Syntax Rules.)
<embedded SQL Fortran program> ::= !! (See the Syntax Rules.)
<embedded SQL MUMPS program> ::= !! (See the Syntax Rules.)
<embedded SQL Pascal program> ::= !! (See the Syntax Rules.)
<embedded SQL PL/I program> ::= !! (See the Syntax Rules.)
<SQL prefix> <statement or declaration> [ <SQL terminator> ]
<statement or declaration> ::=
<declare cursor>
| <dynamic declare cursor>
| <temporary table declaration>
| <embedded authorization declaration>
| <embedded path specification>
| <embedded transform group specification>
| <embedded exception declaration>
| <handler declaration>
| <SQL-invoked routine>
| <SQL procedure statement>
<dynamic declare cursor> ::=
<cursor name> [ <cursor sensitivity> ] [ <cursor scrollability> ] <cursor holdability> ] [ <cursor returnability> ] <statement name>
<embedded authorization clause>
<embedded authorization clause> ::=
<schema name>
| <embedded authorization identifier>
[ <schema name> <embedded authorization identifier>
[ FOR STATIC { ONLY | AND DYNAMIC } ]
<module authorization identifier>
<transform group specification>
<condition> <condition action>
The standard documents 'SQLSTATE ( <SQLSTATE class value> [ , <SQLSTATE subclass value> ] )', but it is not clear why the <left paren>, <comma> and <right paren> are not designated more accurately.
<SQL condition> ::=
<major category>
| <left paren> <SQLSTATE class value> [ <comma> <SQLSTATE subclass value> ] <right paren>
| <constraint name>
<major category> ::= SQLEXCEPTION | SQLWARNING | NOT FOUND
<SQLSTATE char> <SQLSTATE char> !! (See the Syntax Rules.)
<simple Latin upper case letter> | <digit>
<SQLSTATE char> <SQLSTATE char> <SQLSTATE char> !! (See the Syntax Rules.)
<host label identifier> | <unsigned integer> | <host PL/I label variable>
<host label identifier> ::= !! (See the Syntax Rules.)
<host PL/I label variable> ::= !! (See the Syntax Rules.)
This interval primary definition from 9075-5 (SQL/Bindings) is very similar to a previous occurrence from 9075-2 (SQL/Foundation), but adds the optional interval qualifier. The earlier definition is commented out.
<interval primary> ::=
<value expression primary> [ <interval qualifier> ]
| <interval value function>
This module authorization clause definition from 9075-5 (SQL/Bindings) is similar to a previous occurrence from 9075-2 (SQL/Foundation) but the optional 'FOR STATIC ONLY' and 'FOR STATIC AND DYNAMIC' clauses were not present before. The earlier definition is commented out.
<module authorization clause> ::=
<schema name>
| <module authorization identifier>
[ <schema name> <module authorization identifier>
[ FOR STATIC { ONLY | AND DYNAMIC } ]
<preparable statement> ::=
<preparable SQL data statement>
| <preparable SQL schema statement>
| <preparable SQL transaction statement>
| <preparable SQL control statement>
| <preparable SQL session statement>
| <preparable implementation-defined statement>
<preparable SQL data statement> ::=
<delete statement: searched>
| <dynamic single row select statement>
| <insert statement>
| <dynamic select statement>
| <update statement: searched>
| <preparable dynamic delete statement: positioned>
| <preparable dynamic update statement: positioned>
<preparable dynamic delete statement: positioned> ::=
<target table> ] <scope option> ] <cursor name>
<preparable dynamic update statement: positioned> ::=
<target table> ] <set clause list> <scope option> ] <cursor name>
<preparable implementation-defined statement> ::= !! (See the Syntax Rules.)
Automatic translation of this grammar is non-trivial for a number of reasons. One is that the grammar has a number of actions '!! (See the Syntax Rules.)' which cannot be translated automatically. Another is that the grammar contains rules that are usually better handled by the lexical analyzer than the grammar proper. Then there are incomplete rules such as those which reference parts 6 to 10 (they are not defined; indeed, part 7, which was going to be SQL/Temporal, is in complete abeyance), and the packages (almost completely undefined in the grammar). It is not clear whether these can be ignored, or annotated out of the way.
Another complication is automatically generating rules to deal with optional components and repetitive components in the grammar. Square brackets do not contain alternative non-terminals; all those expressions are contained within curly brackets within the square brackets. However, some square brackets do contain alternative terminals. Curly brackets contain and group mandatory elements. However, they are usually used in conjunction with the 'one or more times' repeater ellipsis '...' mark.