Subject Re: [Firebird-Architect] Substring
Author Arno Brinkman
Hi,

> > <character substring function> ::=
> > SUBSTRING <left paren> <character value expression> FROM <start
> > position> [ FOR <string length> ] [ USING <char length units> ]
> > <right paren>
>
> How does USING work here? It wasn't in the doco I used to define this
> function in FB1.

Stripped part of SQL-standard :

----------------------------------------------------------------------------
----
6.29 <string value function>

Function

Specify a function yielding a value of type character string or binary
string.

Format

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

<char length units> ::=
CHARACTERS
|OCTETS

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

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

Syntax Rules

1)The declared type of <string value function>is the declared type of the
immediately contained <character value function>or <blob value
function>.
2)The declared type of <character value function>is the declared type of
the immediately contained <character substring function>,
<regular expression substring function>,<fold>,<transcoding>,
<character transliteration>,<trim function>,<character overlay
function>,
<normalize function>,or <specific type method>.
3)The declared type of a <start position>and <string length>shall be exact
numeric with scale 0 (zero).
4)If <character substring function>CSF is specified,then let DTCVE be the
declared type of the <character value expression>immediately contained
in CSF .The maximum length,character set,and collation of the declared
type DTCSF of CSF are determined as follows:
a)Case:
i)If the declared type of <character value expression>is
fixed-length character
string or variable-length character string,then DTCSF is a
variable-length
character string type with maximum length equal to the fixed
length or
maximum length of DTCVE .
ii)Otherwise,the DTCSF is a large object character string type with
maximum
length equal to the maximum length of DTCVE .
b)The character set and collation of the <character substring
function>are
those of DTCVE .

5)If the character repertoire of <character value expression>is not UCS,
then <char length units>shall not be specified.
6)If USING <char length units>is not specified,then USING CHARACTERS is
implicit.

7)If <regular expression substring function>is specified,then:
a)The declared types of the <escape character>and the
<character value expression>s of the <regular expression substring
function>
shall be character string with the same character repertoire.
b)Case:
i)If the declared type of the first <character value expression>is
fixed-length
character string or variable-length character string,then the
declared type of
the <regular expression substring function>is variable-length
character string
with maximum length equal to the maximum variable length of the
first
<character value expression>.
ii)Otherwise,the declared type of the <regular expression substring
function>is
a character large object type with maximum length equal to the
maximum
variable length of the first <character value expression>.
....
----------------------------------------------------------------------------
----

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/

Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info