OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

regrep-query message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: BNF for SQL LIKE Predicate



Query team,

During last Friday's teleconference I expressed some concern about ad hoc 
adoption of SQL LIKE predicate syntax in our "Clause" element for Registry 
Query. The reason for my reluctance is the complexity of SQL LIKE. I'm 
convinced that XML vendors will not be willing to implement it 
completely.  The trick is then to agree on some reasonable subset.

Attached is a file called "LIKEpredicate.txt" that is copied from the BNF 
for the SQL <like predicate> as specified in ISO/IEC 9075-2:1999.  It is 
very complex because it takes full advantage of the power of SQL and allows 
character expressions, character functions, and numeric functions in its 
specification.

If we decide to go this route -- and I'm still not convinced that a 
majority of the vendors (or Registry clients) will want to do that -- then 
we need to agree on some restrictions. Here are some suggestions:

1) The SQL LIKE predicate for Registry Query shall be a <character like 
predicate>.

2) The <character match value> in a <character like predicate> shall be a 
<column reference> that is a single <column name> that matches a visible 
attribute name of the relevant Registry Query class. The underlying data 
type of this attribute shall be "String".

3) The <character pattern> in a <character like predicate> shall be a 
<character string literal> that does not contain a <character set 
specification> or a <character representation>.

4) The <escape character> in a <character like predicate> shall be a 
<character string literal> that does not contain a <character set 
specification> or a <character representation>.

With these restrictions, the SQL LIKE predicate for Registry Query could be 
reduced to the following BNF representation:

<character like predicate> ::=
    <column name> [ NOT ] LIKE <character pattern>
    [ ESCAPE <escape character> ]

<character pattern> ::= <character string literal>

<escape character> ::= <character string literal>

<character string literal> ::= <quote> [ <character representation>... ] 
<quote>

<character representation> ::= <nonquote character> | <quote symbol>

<nonquote character> ::=  -- Any character from the default character set 
that is not a single quote character, i.e. not the ' character.

<quote symbol> ::= <quote><quote>

But this still leaves the very comprehensive rules for how to specify and 
implement the <character pattern> and <escape character> -- but these rules 
are fully specified in the SQL standard and we could simply point to them.

Regards,
Len



**************************************************************
Len Gallagher                             LGallagher@nist.gov
NIST                                      Work: 301-975-3251
Bldg 820  Room 562                        Home: 301-424-1928
Gaithersburg, MD 20899-8970 USA           Fax: 301-948-6213
**************************************************************


<like predicate> ::=
<character like predicate>
| <octet like predicate>

<character like predicate> ::=
<character match value> [ NOT ] LIKE <character pattern>
[ ESCAPE <escape character> ]

<character match value> ::= <character value expression>

<character pattern> ::= <character value expression>

<escape character> ::= <character value expression>

<octet like predicate> ::=
<octet match value> [ NOT ] LIKE <octet pattern>
[ ESCAPE <escape octet> ]

<octet match value> ::= <blob value expression>

<octet pattern> ::= <blob value expression>

<escape octet> ::= <blob value expression>

<character value expression> ::=
<concatenation>
| <character factor>

<concatenation> ::=
<character value expression> <concatenation operator> <character factor>

<character factor> ::=
<character primary> [ <collate clause> ]

<character primary> ::=
<value expression primary>
| <string value function>

<value expression primary> ::=
<parenthesized value expression>
| <nonparenthesized value expression primary>

<parenthesized value expression> ::=
<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>

<collate clause> ::= COLLATE <collation name>

<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> ::=
SUBSTRING <left paren> <character value expression> FROM <start position>
[ FOR <string length> ] <right paren>

<regular expression substring function> ::=
SUBSTRING <left paren> <character value expression> FROM
<character value expression> FOR <escape character> <right paren>
<fold> ::= { UPPER | LOWER } <left paren> <character value expression> <right paren>

<form-of-use conversion> ::=
CONVERT <left paren> <character value expression>
USING <form-of-use conversion name> <right paren>

<character translation> ::=
TRANSLATE <left paren> <character value expression>
USING <translation name> <right paren>

<trim function> ::=
TRIM <left paren> <trim operands> <right paren>

<trim operands> ::=
[ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>
<trim source> ::= <character value expression>

<trim specification> ::=
LEADING
| TRAILING
| BOTH

<trim character> ::= <character value expression>

<character overlay function> ::=
OVERLAY <left paren> <character value expression>
PLACING <character value expression>
FROM <start position>
[ FOR <string length> ] <right paren>

<specific type method> ::=
<user-defined type value expression> <period> SPECIFICTYPE

<blob value function> ::=
<blob substring function>
| <blob trim function>
| <blob overlay function>

<blob substring function> ::=
SUBSTRING <left paren> <blob value expression> FROM <start position>
[ FOR <string length> ] <right paren>

<blob trim function> ::=
TRIM <left paren> <blob trim operands> <right paren>

<blob trim operands> ::=
[ [ <trim specification> ] [ <trim octet> ] FROM ] <blob trim source>

<blob trim source> ::= <blob value expression>

<trim octet> ::= <blob value expression>

<blob overlay function> ::=
OVERLAY <left paren> <blob value expression>
PLACING <blob value expression>
FROM <start position>
[ FOR <string length> ] <right paren>

<bit value function> ::=
<bit substring function>

<bit substring function> ::=
SUBSTRING <left paren> <bit value expression> FROM <start position>
[ FOR <string length> ] <right paren>

<start position> ::= <numeric value expression>

<string length> ::= <numeric value expression>

<numeric value expression> ::= etc. etc. etc.

<value specification> ::=
<literal>
| <general value specification>

<literal> ::=
<signed numeric literal>
| <general literal>

<unsigned literal> ::=
<unsigned numeric literal>
| <general literal>

<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> }... ]

<introducer> ::= <underscore>

<character representation> ::=
<nonquote character>
| <quote symbol>
<nonquote character> ::= !! See the Syntax Rules.
<quote symbol> ::= <quote><quote>






[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC