Documentation Source Text

Check-in [302d0bb876]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Minor fixes to CAST documentation.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 302d0bb876bdebb506973dbf5f07deb999f18c76
User & Date: dan 2010-08-27 11:20:32.000
Context
2010-08-27
21:09
Add spell check for generated docs using aspell (make spell). (check-in: 047dfe3550 user: shaneh tags: trunk)
11:20
Minor fixes to CAST documentation. (check-in: 302d0bb876 user: dan tags: trunk)
2010-08-26
19:07
Changes to CAST expression documentation to make for more testable statements. (check-in: 6c20f79cbc user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to pages/lang.in.
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
<p>^If the value of &lt;expr&gt; is NULL, then the result of the CAST
expression is also NULL. ^Otherwise, the storage class of the result value
is determined by applying the [rules for determining column affinity] to
the &lt;type-name&gt; specified as part of the CAST expression.

<table border=1>
<tr>
  <th> Affinity of<br>&lt;type-name&gt;
  <th> Conversion Processing
<tr>
  <td> NONE 
  <td> ^Casting a value to a &lt;type-name&gt; with no affinity causes the value to
  be converted into a BLOB.  ^Casting to a BLOB consists of first casting
  the value to TEXT in the [encoding] of the database connection, then
  interpreting the resulting byte sequence as a BLOB instead of as TEXT.







|







1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
<p>^If the value of &lt;expr&gt; is NULL, then the result of the CAST
expression is also NULL. ^Otherwise, the storage class of the result value
is determined by applying the [rules for determining column affinity] to
the &lt;type-name&gt; specified as part of the CAST expression.

<table border=1>
<tr>
  <th> Affinity of &lt;type-name&gt;
  <th> Conversion Processing
<tr>
  <td> NONE 
  <td> ^Casting a value to a &lt;type-name&gt; with no affinity causes the value to
  be converted into a BLOB.  ^Casting to a BLOB consists of first casting
  the value to TEXT in the [encoding] of the database connection, then
  interpreting the resulting byte sequence as a BLOB instead of as TEXT.
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675



1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
<tr>
  <td> REAL
  <td> ^When casting a BLOB value to a REAL, the value is first converted to
        TEXT.
       <p>^When casting a TEXT value to REAL, the longest possible prefix of
        the value that can be interpreted as a real number is extracted from
        the TEXT value and the remainder ignored. ^Any leading spaces in the
        TEXT value are ignored when converging from TEXT to REAL. ^If there is
        no prefix that can be interpreted as a real number, the result of the
        conversion is 0.0.

<tr>
  <td> INTEGER
  <td> ^When casting a BLOB value to INTEGER, the value is first converted to
        TEXT.
       <p>^When casting a TEXT value to INTEGER, the longest possible prefix of
        the value that can be interpreted as an integer number is extracted from
        the TEXT value and the remainder ignored. ^Any leading spaces in the
        TEXT value when converting from TEXT to INTEGER are ignored. ^If there
        is no prefix that can be interpreted as an integer number, the result
        of the conversion is 0.

      <p>^A cast of a REAL value into an INTEGER will truncate the fractional
      part of the REAL.  ^If an REAL is too large to be represented as an 
      INTEGER then the result of the cast is the largest negative integer: 
      -9223372036854775808.

<tr>
  <td> NUMERIC
  <td> ^Casting a value into NUMERIC first does a forced conversion into REAL
  but then further converts the result into INTEGER if and only if the
  conversion from REAL to INTEGER is lossless and reversible.  This is the only
  context in SQLite where the NUMERIC and INTEGER [affinities] behave differently.




</tr>

</table>

<p>^Note that the result from casting any non-BLOB value into a 
BLOB and the result from casting any BLOB value into a non-BLOB value
will be different depending on whether the database [encoding] is UTF-8,
UTF-16be, or UTF-16le.

<h3>Functions</h3>
<p>^Both [corefunc|simple] and [aggfunc|aggregate] functions are supported.
(For presentation purposes, simple functions are further subdivided into
[corefunc | core functions] and [datefunc | date-time functions].)
^A simple function can be used in any expression.  ^Simple functions return







|

|



















|
|
|
|
>
>
>







|







1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
<tr>
  <td> REAL
  <td> ^When casting a BLOB value to a REAL, the value is first converted to
        TEXT.
       <p>^When casting a TEXT value to REAL, the longest possible prefix of
        the value that can be interpreted as a real number is extracted from
        the TEXT value and the remainder ignored. ^Any leading spaces in the
        TEXT value are ignored when converging from TEXT to REAL. ^(If there is
        no prefix that can be interpreted as a real number, the result of the
        conversion is 0.0.)^

<tr>
  <td> INTEGER
  <td> ^When casting a BLOB value to INTEGER, the value is first converted to
        TEXT.
       <p>^When casting a TEXT value to INTEGER, the longest possible prefix of
        the value that can be interpreted as an integer number is extracted from
        the TEXT value and the remainder ignored. ^Any leading spaces in the
        TEXT value when converting from TEXT to INTEGER are ignored. ^If there
        is no prefix that can be interpreted as an integer number, the result
        of the conversion is 0.

      <p>^A cast of a REAL value into an INTEGER will truncate the fractional
      part of the REAL.  ^If an REAL is too large to be represented as an 
      INTEGER then the result of the cast is the largest negative integer: 
      -9223372036854775808.

<tr>
  <td> NUMERIC
  <td> ^Casting a TEXT or BLOB value into NUMERIC first does a forced
   conversion into REAL but then further converts the result into INTEGER if
   and only if the conversion from REAL to INTEGER is lossless and reversible.
   This is the only context in SQLite where the NUMERIC and INTEGER [affinities]
   behave differently.
   <p> ^Casting a REAL or INTEGER value to NUMERIC is a no-op, even if a real
   value could be losslessly converted to an integer.

</tr>

</table>

<p>^Note that the result from casting any non-BLOB value into a 
BLOB and the result from casting any BLOB value into a non-BLOB value
may be different depending on whether the database [encoding] is UTF-8,
UTF-16be, or UTF-16le.

<h3>Functions</h3>
<p>^Both [corefunc|simple] and [aggfunc|aggregate] functions are supported.
(For presentation purposes, simple functions are further subdivided into
[corefunc | core functions] and [datefunc | date-time functions].)
^A simple function can be used in any expression.  ^Simple functions return