Artifact
a9026b69b18db48664908bb5d85c3636887fce9c:
Wiki page
[4.1.0 Changes] by
sandro
2013-03-05 20:12:59.
0000: 44 20 32 30 31 33 2d 30 33 2d 30 35 54 32 30 3a D 2013-03-05T20:
0010: 31 32 3a 35 39 2e 32 38 31 0a 4c 20 34 2e 31 2e 12:59.281.L 4.1.
0020: 30 5c 73 43 68 61 6e 67 65 73 0a 55 20 73 61 6e 0\sChanges.U san
0030: 64 72 6f 0a 57 20 38 32 31 32 0a 62 61 63 6b 20 dro.W 8212.back
0040: 74 6f 20 58 6d 6c 42 6c 6f 62 20 3c 61 20 68 72 to XmlBlob <a hr
0050: 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e ef="https://www.
0060: 67 61 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 73 gaia-gis.it/foss
0070: 69 6c 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 65 il/libspatialite
0080: 2f 77 69 6b 69 3f 6e 61 6d 65 3d 58 6d 6c 42 6c /wiki?name=XmlBl
0090: 6f 62 2b 61 6e 64 2b 56 69 72 74 75 61 6c 58 50 ob+and+VirtualXP
00a0: 61 74 68 22 3e 6d 61 69 6e 20 70 61 67 65 3c 2f ath">main page</
00b0: 61 3e 0d 0a 3c 68 32 3e 4e 65 77 20 53 51 4c 20 a>..<h2>New SQL
00c0: 66 75 6e 63 74 69 6f 6e 73 20 69 6e 74 72 6f 64 functions introd
00d0: 75 63 65 64 20 69 6e 20 34 2e 31 2e 30 3c 2f 68 uced in 4.1.0</h
00e0: 32 3e 0d 0a 3c 68 33 3e 47 65 6e 65 72 69 63 20 2>..<h3>Generic
00f0: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 2d 20 SQL functions -
0100: 74 79 70 65 20 63 61 73 74 69 6e 67 3c 2f 68 33 type casting</h3
0110: 3e 0d 0a 53 51 4c 69 74 65 20 6f 66 66 65 72 73 >..SQLite offers
0120: 20 6a 75 73 74 20 61 20 76 65 72 79 20 62 61 73 just a very bas
0130: 69 63 20 74 79 70 65 20 63 68 65 63 6b 69 6e 67 ic type checking
0140: 3b 20 74 68 69 73 20 69 73 20 73 6f 6d 65 74 69 ; this is someti
0150: 6d 65 73 20 75 73 65 66 75 6c 2c 20 62 75 74 20 mes useful, but
0160: 63 6f 75 6c 64 20 62 65 20 72 65 61 6c 6c 79 20 could be really
0170: 65 6e 6e 6f 79 69 6e 67 20 76 65 72 79 20 6f 66 ennoying very of
0180: 74 65 6e 2e 3c 62 72 3e 0d 0a 3c 76 65 72 62 61 ten.<br>..<verba
0190: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 27 31 27 tim>..SELECT '1'
01a0: 2c 20 54 79 70 65 4f 66 28 20 27 31 27 20 29 2c , TypeOf( '1' ),
01b0: 20 43 41 53 54 20 28 20 27 31 27 20 41 53 20 49 CAST ( '1' AS I
01c0: 4e 54 45 47 45 52 20 29 2c 20 54 79 70 65 4f 66 NTEGER ), TypeOf
01d0: 28 20 43 41 53 54 20 28 20 27 31 27 20 41 53 20 ( CAST ( '1' AS
01e0: 49 4e 54 45 47 45 52 20 29 20 29 3b 0d 0a 3c 2f INTEGER ) );..</
01f0: 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c verbatim>..<tabl
0200: 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c e border="1" cel
0210: 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c lspacing="4" cel
0220: 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c lpadding="4">..<
0230: 74 72 3e 3c 74 68 3e 27 31 27 3c 2f 74 68 3e 3c tr><th>'1'</th><
0240: 74 68 3e 54 79 70 65 4f 66 28 20 27 31 27 20 29 th>TypeOf( '1' )
0250: 3c 2f 74 68 3e 3c 74 68 3e 43 41 53 54 20 28 20 </th><th>CAST (
0260: 27 31 27 20 41 53 20 49 4e 54 45 47 45 52 20 29 '1' AS INTEGER )
0270: 3c 2f 74 68 3e 3c 74 68 3e 54 79 70 65 4f 66 28 </th><th>TypeOf(
0280: 20 43 41 53 54 20 28 20 27 31 27 20 41 53 20 49 CAST ( '1' AS I
0290: 4e 54 45 47 45 52 20 29 20 29 3c 2f 74 68 3e 3c NTEGER ) )</th><
02a0: 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 31 3c /tr>..<tr><td>1<
02b0: 2f 74 64 3e 3c 74 64 3e 74 65 78 74 3c 2f 74 64 /td><td>text</td
02c0: 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 ><td align="righ
02d0: 74 22 3e 31 3c 2f 74 64 3e 3c 74 64 3e 69 6e 74 t">1</td><td>int
02e0: 65 67 65 72 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f eger</td></tr></
02f0: 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 table><br>..The
0300: 53 51 4c 20 3c 62 3e 43 41 53 54 3c 2f 62 3e 20 SQL <b>CAST</b>
0310: 6f 70 65 72 61 74 6f 72 20 61 6c 72 65 61 64 79 operator already
0320: 20 73 75 70 70 6f 72 74 73 20 74 68 65 20 70 6f supports the po
0330: 73 73 69 62 69 6c 69 74 79 20 74 6f 20 65 78 70 ssibility to exp
0340: 6c 69 63 69 74 6c 79 20 73 65 74 20 61 20 64 61 licitly set a da
0350: 74 61 2d 74 79 70 65 3b 20 6e 6f 77 20 73 74 61 ta-type; now sta
0360: 72 74 69 6e 67 20 73 69 6e 63 65 20 34 2e 31 2e rting since 4.1.
0370: 30 20 53 70 61 74 69 61 4c 69 74 65 20 73 75 70 0 SpatiaLite sup
0380: 70 6f 72 74 73 20 66 65 77 20 53 51 4c 20 66 75 ports few SQL fu
0390: 6e 63 74 69 6f 6e 73 20 70 65 72 66 6f 72 6d 69 nctions performi
03a0: 6e 67 20 74 68 65 20 73 61 6d 65 20 74 61 73 6b ng the same task
03b0: 2e 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 .<br>..<u>Please
03c0: 20 6e 6f 74 65 3c 2f 75 3e 3a 20 73 6f 6d 65 20 note</u>: some
03d0: 73 75 62 74 6c 65 20 64 69 66 66 65 72 65 6e 63 subtle differenc
03e0: 65 73 20 65 78 69 73 74 73 20 68 65 72 65 20 61 es exists here a
03f0: 6e 64 20 74 68 65 72 65 3b 20 70 6c 65 61 73 65 nd there; please
0400: 20 63 61 72 65 66 75 6c 6c 79 20 72 65 61 64 20 carefully read
0410: 74 68 69 73 20 64 6f 63 75 6d 65 6e 74 61 74 69 this documentati
0420: 6f 6e 20 70 61 67 65 2e 0d 0a 3c 76 65 72 62 61 on page...<verba
0430: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 61 73 tim>..SELECT Cas
0440: 74 54 6f 49 6e 74 65 67 65 72 28 20 31 20 29 2c tToInteger( 1 ),
0450: 20 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20 CastToInteger(
0460: 31 2e 34 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 1.4 ), CastToInt
0470: 65 67 65 72 28 20 31 2e 36 20 29 2c 20 0d 0a 20 eger( 1.6 ), ..
0480: 20 20 20 43 61 73 74 54 6f 49 6e 74 65 67 65 72 CastToInteger
0490: 28 20 27 31 32 33 27 20 29 2c 20 43 61 73 74 54 ( '123' ), CastT
04a0: 6f 49 6e 74 65 67 65 72 28 20 27 61 6c 70 68 61 oInteger( 'alpha
04b0: 27 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 65 67 ' ), CastToInteg
04c0: 65 72 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 er ( zeroblob(4)
04d0: 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e );..</verbatim>
04e0: 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d ..<table border=
04f0: 22 31 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d "1" cellspacing=
0500: 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d "4" cellpadding=
0510: 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 "4">..<tr><th>Ca
0520: 73 74 54 6f 49 6e 74 65 67 65 72 28 20 31 20 29 stToInteger( 1 )
0530: 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 49 </th><th>CastToI
0540: 6e 74 65 67 65 72 28 20 31 2e 34 20 29 3c 2f 74 nteger( 1.4 )</t
0550: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e 74 65 h><th>CastToInte
0560: 67 65 72 28 20 31 2e 36 20 29 3c 2f 74 68 3e 3c ger( 1.6 )</th><
0570: 74 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 th>CastToInteger
0580: 28 20 27 31 32 33 27 20 29 3c 2f 74 68 3e 3c 74 ( '123' )</th><t
0590: 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 h>CastToInteger(
05a0: 20 27 61 6c 70 68 61 27 20 29 3c 2f 74 68 3e 3c 'alpha' )</th><
05b0: 74 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 th>CastToInteger
05c0: 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 ( zeroblob(4) )
05d0: 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e </th></tr>..<tr>
05e0: 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 <td align="right
05f0: 22 3e 31 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 ">1</td><td alig
0600: 6e 3d 22 72 69 67 68 74 22 3e 31 3c 2f 74 64 3e n="right">1</td>
0610: 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 <td align="right
0620: 22 3e 32 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 ">2</td><td alig
0630: 6e 3d 22 72 69 67 68 74 22 3e 31 32 33 3c 2f 74 n="right">123</t
0640: 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c d><td>NULL</td><
0650: 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 2f 74 72 td>NULL</td></tr
0660: 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 ></table><br>..T
0670: 68 65 20 3c 62 3e 43 61 73 74 54 6f 49 6e 74 65 he <b>CastToInte
0680: 67 65 72 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 ger()</b> SQL fu
0690: 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 61 74 74 65 nction will atte
06a0: 6d 70 74 20 74 6f 20 72 65 74 75 72 6e 20 61 20 mpt to return a
06b0: 76 61 6c 75 65 20 6f 66 20 74 68 65 20 3c 62 3e value of the <b>
06c0: 49 6e 74 65 67 65 72 3c 2f 62 3e 20 64 61 74 61 Integer</b> data
06d0: 2d 74 79 70 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c -type, or <b>NUL
06e0: 4c 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 6f 6e 76 L</b> if no conv
06f0: 65 72 73 69 6f 6e 20 69 73 20 70 6f 73 73 69 62 ersion is possib
0700: 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 le...<ul>..<li>a
0710: 6e 20 49 6e 74 65 67 65 72 20 69 6e 70 75 74 20 n Integer input
0720: 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 62 65 argument will be
0730: 20 72 65 74 75 72 6e 65 64 20 61 62 73 6f 6c 75 returned absolu
0740: 74 65 6c 79 20 75 6e 61 66 66 65 63 74 65 64 2e tely unaffected.
0750: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75 </li>..<li>a Dou
0760: 62 6c 65 20 69 6e 70 75 74 20 61 72 67 75 6d 65 ble input argume
0770: 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 nt will return t
0780: 68 65 20 3c 75 3e 6e 65 61 72 65 73 74 3c 2f 75 he <u>nearest</u
0790: 3e 20 49 6e 74 65 67 65 72 20 76 61 6c 75 65 20 > Integer value
07a0: 28 61 66 74 65 72 20 61 70 70 6c 79 69 6e 67 20 (after applying
07b0: 3c 62 3e 34 2f 35 3c 2f 62 3e 20 72 6f 75 6e 64 <b>4/5</b> round
07c0: 69 6e 67 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e ing).</li>..<li>
07d0: 61 20 54 65 78 74 20 69 6e 70 75 74 20 61 72 67 a Text input arg
07e0: 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 ument will retur
07f0: 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 n the correspond
0800: 69 6e 67 20 49 6e 74 65 67 65 72 20 76 61 6c 75 ing Integer valu
0810: 65 20 6f 6e 6c 79 20 69 66 20 74 68 65 20 74 65 e only if the te
0820: 78 74 20 73 74 72 69 6e 67 20 72 65 70 72 65 73 xt string repres
0830: 65 6e 74 73 20 61 20 76 61 6c 69 64 20 6e 75 6d ents a valid num
0840: 62 65 72 20 28 65 76 65 6e 20 61 20 64 65 63 69 ber (even a deci
0850: 6d 61 6c 20 6f 6e 65 29 3a 20 69 66 20 74 68 65 mal one): if the
0860: 20 74 65 78 74 20 73 74 72 69 6e 67 20 63 61 6e text string can
0870: 6e 6f 74 20 62 65 20 63 6f 6e 76 65 72 74 65 64 not be converted
0880: 20 74 6f 20 61 20 6e 75 6d 62 65 72 20 4e 55 4c to a number NUL
0890: 4c 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e L will be return
08a0: 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e ed.</li>..<li>an
08b0: 79 20 42 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 y BLOB input arg
08c0: 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 ument will retur
08d0: 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c n a NULL value.<
08e0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 /li>..<li>any NU
08f0: 4c 4c 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e LL input argumen
0900: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 t will return a
0910: 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e NULL value.</li>
0920: 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 68 72 3e 0d 0a 3c ..</ul>..<hr>..<
0930: 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 verbatim>..SELEC
0940: 54 20 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20 T CastToDouble(
0950: 31 20 29 2c 20 43 61 73 74 54 6f 44 6f 75 62 6c 1 ), CastToDoubl
0960: 65 28 20 31 2e 32 33 20 29 2c 20 43 61 73 74 54 e( 1.23 ), CastT
0970: 6f 44 6f 75 62 6c 65 28 20 27 31 32 33 2e 34 35 oDouble( '123.45
0980: 27 20 29 2c 0d 0a 20 20 20 20 43 61 73 74 54 6f ' ),.. CastTo
0990: 44 6f 75 62 6c 65 28 20 27 61 6c 70 68 61 27 20 Double( 'alpha'
09a0: 29 2c 20 43 61 73 74 54 6f 44 6f 75 62 6c 65 20 ), CastToDouble
09b0: 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3b ( zeroblob(4) );
09c0: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c ..</verbatim>..<
09d0: 74 61 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 table border="1"
09e0: 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 cellspacing="4"
09f0: 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 cellpadding="4"
0a00: 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 >..<tr><th>CastT
0a10: 6f 44 6f 75 62 6c 65 28 20 31 20 29 3c 2f 74 68 oDouble( 1 )</th
0a20: 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 6c ><th>CastToDoubl
0a30: 65 28 20 31 2e 32 33 20 29 3c 2f 74 68 3e 3c 74 e( 1.23 )</th><t
0a40: 68 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20 h>CastToDouble(
0a50: 27 31 32 33 2e 34 35 27 20 29 3c 2f 74 68 3e 3c '123.45' )</th><
0a60: 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 th>CastToDouble(
0a70: 20 27 61 6c 70 68 61 27 20 29 3c 2f 74 68 3e 3c 'alpha' )</th><
0a80: 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 20 th>CastToDouble
0a90: 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3c ( zeroblob(4) )<
0aa0: 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c /th></tr>..<tr><
0ab0: 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 td align="right"
0ac0: 3e 31 2e 30 30 30 30 30 30 3c 2f 74 64 3e 3c 74 >1.000000</td><t
0ad0: 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e d align="right">
0ae0: 31 2e 32 33 30 30 30 30 3c 2f 74 64 3e 3c 74 64 1.230000</td><td
0af0: 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 align="right">1
0b00: 32 33 2e 34 35 30 30 30 3c 2f 74 64 3e 3c 74 64 23.45000</td><td
0b10: 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 >NULL</td><td>NU
0b20: 4c 4c 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 LL</td></tr></ta
0b30: 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 ble><br>..The <b
0b40: 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 29 3c >CastToDouble()<
0b50: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e /b> SQL function
0b60: 20 77 69 6c 6c 20 61 74 74 65 6d 70 74 20 74 6f will attempt to
0b70: 20 72 65 74 75 72 6e 20 61 20 76 61 6c 75 65 20 return a value
0b80: 6f 66 20 74 68 65 20 3c 62 3e 44 6f 75 62 6c 65 of the <b>Double
0b90: 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70 65 2c 20 </b> data-type,
0ba0: 6f 72 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e 20 69 or <b>NULL</b> i
0bb0: 66 20 6e 6f 20 63 6f 6e 76 65 72 73 69 6f 6e 20 f no conversion
0bc0: 69 73 20 70 6f 73 73 69 62 6c 65 2e 0d 0a 3c 75 is possible...<u
0bd0: 6c 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74 65 67 l>..<li>an Integ
0be0: 65 72 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e er input argumen
0bf0: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 t will return th
0c00: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 e corresponding
0c10: 44 6f 75 62 6c 65 20 76 61 6c 75 65 2e 3c 2f 6c Double value.</l
0c20: 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75 62 6c 65 i>..<li>a Double
0c30: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 input argument
0c40: 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 will be returned
0c50: 20 61 62 73 6f 6c 75 74 65 6c 79 20 75 6e 61 66 absolutely unaf
0c60: 66 65 63 74 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c fected.</li>..<l
0c70: 69 3e 61 20 54 65 78 74 20 69 6e 70 75 74 20 61 i>a Text input a
0c80: 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 rgument will ret
0c90: 75 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f urn the correspo
0ca0: 6e 64 69 6e 67 20 44 6f 75 62 6c 65 20 76 61 6c nding Double val
0cb0: 75 65 20 6f 6e 6c 79 20 69 66 20 74 68 65 20 74 ue only if the t
0cc0: 65 78 74 20 73 74 72 69 6e 67 20 72 65 70 72 65 ext string repre
0cd0: 73 65 6e 74 73 20 61 20 76 61 6c 69 64 20 6e 75 sents a valid nu
0ce0: 6d 62 65 72 3a 20 69 66 20 74 68 65 20 74 65 78 mber: if the tex
0cf0: 74 20 73 74 72 69 6e 67 20 63 61 6e 6e 6f 74 20 t string cannot
0d00: 62 65 20 63 6f 6e 76 65 72 74 65 64 20 74 6f 20 be converted to
0d10: 61 20 6e 75 6d 62 65 72 20 4e 55 4c 4c 20 77 69 a number NULL wi
0d20: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 2e 3c ll be returned.<
0d30: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 42 4c /li>..<li>any BL
0d40: 4f 42 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e OB input argumen
0d50: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 t will return a
0d60: 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e NULL value.</li>
0d70: 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c 20 69 ..<li>any NULL i
0d80: 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 nput argument wi
0d90: 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c ll return a NULL
0da0: 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f value.</li>..</
0db0: 75 6c 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 ul>..<hr>..<verb
0dc0: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 61 atim>..SELECT Ca
0dd0: 73 74 54 6f 54 65 78 74 28 20 31 20 29 2c 20 43 stToText( 1 ), C
0de0: 61 73 74 54 6f 54 65 78 74 28 20 31 2e 35 20 29 astToText( 1.5 )
0df0: 2c 20 43 61 73 74 54 6f 54 65 78 74 28 20 27 61 , CastToText( 'a
0e00: 6c 70 68 61 27 20 29 2c 20 43 61 73 74 54 6f 54 lpha' ), CastToT
0e10: 65 78 74 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 ext ( zeroblob(4
0e20: 29 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d ) );..</verbatim
0e30: 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 >..<table border
0e40: 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 ="1" cellspacing
0e50: 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 ="4" cellpadding
0e60: 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 ="4">..<tr><th>C
0e70: 61 73 74 54 6f 54 65 78 74 28 20 31 20 29 3c 2f astToText( 1 )</
0e80: 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 th><th>CastToTex
0e90: 74 28 20 31 2e 35 20 29 3c 2f 74 68 3e 3c 74 68 t( 1.5 )</th><th
0ea0: 3e 43 61 73 74 54 6f 54 65 78 74 28 20 27 61 6c >CastToText( 'al
0eb0: 70 68 61 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 pha' )</th><th>C
0ec0: 61 73 74 54 6f 54 65 78 74 20 28 20 7a 65 72 6f astToText ( zero
0ed0: 62 6c 6f 62 28 34 29 20 29 3c 2f 74 68 3e 3c 2f blob(4) )</th></
0ee0: 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 31 3c 2f tr>..<tr><td>1</
0ef0: 74 64 3e 3c 74 64 3e 31 2e 35 3c 2f 74 64 3e 3c td><td>1.5</td><
0f00: 74 64 3e 61 6c 70 68 61 3c 2f 74 64 3e 3c 74 64 td>alpha</td><td
0f10: 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 2f 74 72 3e 3c >NULL</td></tr><
0f20: 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 /table><br>..The
0f30: 20 3c 62 3e 43 61 73 74 54 6f 54 65 78 74 28 29 <b>CastToText()
0f40: 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f </b> SQL functio
0f50: 6e 20 77 69 6c 6c 20 61 74 74 65 6d 70 74 20 74 n will attempt t
0f60: 6f 20 72 65 74 75 72 6e 20 61 20 76 61 6c 75 65 o return a value
0f70: 20 6f 66 20 74 68 65 20 3c 62 3e 54 65 78 74 3c of the <b>Text<
0f80: 2f 62 3e 20 64 61 74 61 2d 74 79 70 65 2c 20 6f /b> data-type, o
0f90: 72 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e 20 69 66 r <b>NULL</b> if
0fa0: 20 6e 6f 20 63 6f 6e 76 65 72 73 69 6f 6e 20 69 no conversion i
0fb0: 73 20 70 6f 73 73 69 62 6c 65 2e 0d 0a 3c 75 6c s possible...<ul
0fc0: 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74 65 67 65 >..<li>an Intege
0fd0: 72 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 r input argument
0fe0: 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 will return the
0ff0: 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 54 corresponding T
1000: 65 78 74 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d ext value.</li>.
1010: 0a 3c 6c 69 3e 61 20 44 6f 75 62 6c 65 20 69 6e .<li>a Double in
1020: 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c put argument wil
1030: 6c 20 62 65 20 72 65 74 75 72 6e 20 74 68 65 20 l be return the
1040: 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 54 65 corresponding Te
1050: 78 74 20 76 61 6c 75 65 3b 20 6e 6f 20 73 69 67 xt value; no sig
1060: 6e 69 66 69 63 61 74 69 76 65 20 64 65 63 69 6d nificative decim
1070: 61 6c 20 64 69 67 69 74 20 77 69 6c 6c 20 62 65 al digit will be
1080: 20 73 75 70 70 72 65 73 73 65 64 2e 3c 2f 6c 69 suppressed.</li
1090: 3e 0d 0a 3c 6c 69 3e 61 20 54 65 78 74 20 69 6e >..<li>a Text in
10a0: 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c put argument wil
10b0: 6c 20 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 l return the cor
10c0: 72 65 73 70 6f 6e 64 69 6e 67 20 44 6f 75 62 6c responding Doubl
10d0: 65 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c e value.</li>..<
10e0: 6c 69 3e 61 6e 79 20 42 4c 4f 42 20 69 6e 70 75 li>any BLOB inpu
10f0: 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 t argument will
1100: 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61 return a NULL va
1110: 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 lue.</li>..<li>a
1120: 6e 79 20 4e 55 4c 4c 20 69 6e 70 75 74 20 61 72 ny NULL input ar
1130: 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 gument will retu
1140: 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e rn a NULL value.
1150: 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 76 </li>..</ul>..<v
1160: 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 erbatim>..SELECT
1170: 20 43 61 73 74 54 6f 54 65 78 74 28 20 31 2c 20 CastToText( 1,
1180: 34 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 28 4 ), CastToText(
1190: 20 31 32 33 34 2c 20 32 20 29 2c 20 43 61 73 74 1234, 2 ), Cast
11a0: 54 6f 54 65 78 74 28 20 31 2c 20 38 20 29 2c 20 ToText( 1, 8 ),
11b0: 43 61 73 74 54 6f 54 65 78 74 28 20 31 2e 35 2c CastToText( 1.5,
11c0: 20 34 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 4 );..</verbati
11d0: 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 m>..<table borde
11e0: 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 69 6e r="1" cellspacin
11f0: 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e g="4" cellpaddin
1200: 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e g="4">..<tr><th>
1210: 43 61 73 74 54 6f 54 65 78 74 28 20 31 2c 20 34 CastToText( 1, 4
1220: 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 )</th><th>CastT
1230: 6f 54 65 78 74 28 20 31 32 33 34 2c 20 32 20 29 oText( 1234, 2 )
1240: 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54 </th><th>CastToT
1250: 65 78 74 28 20 31 2c 20 38 20 29 3c 2f 74 68 3e ext( 1, 8 )</th>
1260: 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 28 20 <th>CastToText(
1270: 31 2e 35 2c 20 34 20 29 3c 2f 74 68 3e 3c 2f 74 1.5, 4 )</th></t
1280: 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 30 30 30 31 r>..<tr><td>0001
1290: 3c 2f 74 64 3e 3c 74 64 3e 31 32 33 34 3c 2f 74 </td><td>1234</t
12a0: 64 3e 3c 74 64 3e 30 30 30 30 30 30 30 31 3c 2f d><td>00000001</
12b0: 74 64 3e 3c 74 64 3e 30 30 30 31 2e 35 3c 2f 74 td><td>0001.5</t
12c0: 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c d></tr></table><
12d0: 62 72 3e 0d 0a 41 6e 20 6f 76 65 72 6c 6f 61 64 br>..An overload
12e0: 65 64 20 76 65 72 73 69 6f 6e 20 6f 66 20 3c 62 ed version of <b
12f0: 3e 43 61 73 74 54 6f 54 65 78 74 28 29 3c 2f 62 >CastToText()</b
1300: 3e 20 69 73 20 73 75 70 70 6f 72 74 65 64 20 61 > is supported a
1310: 73 20 77 65 6c 6c 2c 20 62 75 74 20 6f 6e 6c 79 s well, but only
1320: 20 77 68 65 6e 20 74 68 65 20 69 6e 70 75 74 20 when the input
1330: 61 72 67 75 6d 65 6e 74 20 69 73 20 6f 66 20 74 argument is of t
1340: 68 65 20 49 6e 74 65 67 65 72 20 6f 72 20 44 6f he Integer or Do
1350: 75 62 6c 65 20 64 61 74 61 2d 74 79 70 65 3a 20 uble data-type:
1360: 69 6e 20 74 68 69 73 20 63 61 73 65 20 61 20 73 in this case a s
1370: 65 63 6f 6e 64 20 49 6e 74 65 67 65 72 20 61 72 econd Integer ar
1380: 67 75 6d 65 6e 74 20 63 6f 75 6c 64 20 62 65 20 gument could be
1390: 6f 70 74 69 6f 6e 61 6c 6c 79 20 73 70 65 63 69 optionally speci
13a0: 66 69 65 64 2c 20 61 6e 64 20 77 69 6c 6c 20 62 fied, and will b
13b0: 65 20 69 6e 74 65 72 70 72 65 74 65 72 65 64 20 e interpretered
13c0: 61 64 20 3c 62 3e 7a 65 72 6f 2d 70 61 64 64 69 ad <b>zero-paddi
13d0: 6e 67 2d 6c 65 6e 67 74 68 3c 2f 62 3e 2e 3c 62 ng-length</b>.<b
13e0: 72 3e 0d 0a 69 2e 65 2e 20 74 68 65 20 72 65 74 r>..i.e. the ret
13f0: 75 72 6e 65 64 20 54 65 78 74 20 73 74 72 69 6e urned Text strin
1400: 67 20 69 6e 20 74 68 69 73 20 63 61 73 65 20 77 g in this case w
1410: 69 6c 6c 20 68 61 76 65 20 61 6e 20 69 6e 74 65 ill have an inte
1420: 67 65 72 20 70 61 72 74 20 61 74 20 6c 65 61 73 ger part at leas
1430: 74 20 6f 66 20 74 68 65 20 73 70 65 63 69 66 69 t of the specifi
1440: 65 64 20 6c 65 6e 67 74 68 2c 20 61 6e 64 20 65 ed length, and e
1450: 76 65 6e 74 75 61 6c 6c 79 20 70 61 64 64 65 64 ventually padded
1460: 20 62 79 20 69 6e 73 65 72 74 69 6e 67 20 6e 6f by inserting no
1470: 74 20 73 69 67 6e 69 66 69 63 61 74 69 76 65 20 t significative
1480: 6c 65 61 64 69 6e 67 20 5a 45 52 4f 65 73 2e 3c leading ZEROes.<
1490: 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 br>..<hr>..<verb
14a0: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 61 atim>..SELECT Ca
14b0: 73 74 54 6f 42 6c 6f 62 28 20 31 20 29 2c 20 43 stToBlob( 1 ), C
14c0: 61 73 74 54 6f 42 6c 6f 62 28 20 31 2e 35 20 29 astToBlob( 1.5 )
14d0: 2c 20 48 65 78 28 20 43 61 73 74 54 6f 42 6c 6f , Hex( CastToBlo
14e0: 62 28 20 27 61 6c 70 68 61 27 20 29 20 29 2c 20 b( 'alpha' ) ),
14f0: 48 65 78 20 28 20 43 61 73 74 54 6f 42 6c 6f 62 Hex ( CastToBlob
1500: 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 ( zeroblob(4) )
1510: 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e );..</verbatim>
1520: 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d ..<table border=
1530: 22 31 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d "1" cellspacing=
1540: 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d "4" cellpadding=
1550: 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 "4">..<tr><th>Ca
1560: 73 74 54 6f 42 6c 6f 62 28 20 31 20 29 3c 2f 74 stToBlob( 1 )</t
1570: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 42 6c 6f 62 h><th>CastToBlob
1580: 28 20 31 2e 35 20 29 3c 2f 74 68 3e 3c 74 68 3e ( 1.5 )</th><th>
1590: 48 65 78 28 20 43 61 73 74 54 6f 42 6c 6f 62 28 Hex( CastToBlob(
15a0: 20 27 61 6c 70 68 61 27 20 29 20 29 3c 2f 74 68 'alpha' ) )</th
15b0: 3e 3c 74 68 3e 48 65 78 28 20 43 61 73 74 54 6f ><th>Hex( CastTo
15c0: 54 65 78 74 20 28 20 7a 65 72 6f 62 6c 6f 62 28 Text ( zeroblob(
15d0: 34 29 20 29 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 4) ) )</th></tr>
15e0: 0d 0a 3c 74 72 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f ..<tr><td>NULL</
15f0: 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e td><td>NULL</td>
1600: 3c 74 64 3e 36 31 36 43 37 30 36 38 36 31 3c 2f <td>616C706861</
1610: 74 64 3e 3c 74 64 3e 30 30 30 30 30 30 30 30 3c td><td>00000000<
1620: 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 /td></tr></table
1630: 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 3e 43 61 ><br>..The <b>Ca
1640: 73 74 54 6f 42 6c 6f 62 28 29 3c 2f 62 3e 20 53 stToBlob()</b> S
1650: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c QL function will
1660: 20 61 74 74 65 6d 70 74 20 74 6f 20 72 65 74 75 attempt to retu
1670: 72 6e 20 61 20 76 61 6c 75 65 20 6f 66 20 74 68 rn a value of th
1680: 65 20 3c 62 3e 42 4c 4f 42 3c 2f 62 3e 20 64 61 e <b>BLOB</b> da
1690: 74 61 2d 74 79 70 65 2c 20 6f 72 20 3c 62 3e 4e ta-type, or <b>N
16a0: 55 4c 4c 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 6f ULL</b> if no co
16b0: 6e 76 65 72 73 69 6f 6e 20 69 73 20 70 6f 73 73 nversion is poss
16c0: 69 62 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 ible...<ul>..<li
16d0: 3e 61 6e 20 49 6e 74 65 67 65 72 20 69 6e 70 75 >an Integer inpu
16e0: 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 t argument will
16f0: 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61 return a NULL va
1700: 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 lue.</li>..<li>a
1710: 20 44 6f 75 62 6c 65 20 69 6e 70 75 74 20 61 72 Double input ar
1720: 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 gument will retu
1730: 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e rn a NULL value.
1740: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 54 65 78 </li>..<li>a Tex
1750: 74 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 t input argument
1760: 20 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 will return th
1770: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 e corresponding
1780: 42 4c 4f 42 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e BLOB value.</li>
1790: 0d 0a 3c 6c 69 3e 61 6e 79 20 42 4c 4f 42 20 69 ..<li>any BLOB i
17a0: 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 nput argument wi
17b0: 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 20 63 6f ll return the co
17c0: 72 72 65 73 70 6f 6e 64 69 6e 67 20 42 4c 4f 42 rresponding BLOB
17d0: 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c value.</li>..<l
17e0: 69 3e 61 6e 79 20 4e 55 4c 4c 20 69 6e 70 75 74 i>any NULL input
17f0: 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 argument will r
1800: 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c eturn a NULL val
1810: 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d ue.</li>..</ul>.
1820: 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d .<hr>..<verbatim
1830: 3e 0d 0a 53 45 4c 45 43 54 20 46 6f 72 63 65 41 >..SELECT ForceA
1840: 73 4e 75 6c 6c 28 20 27 61 27 2c 20 27 62 27 20 sNull( 'a', 'b'
1850: 29 2c 20 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 ), ForceAsNull(
1860: 27 61 62 63 64 27 2c 20 27 61 62 63 64 27 20 29 'abcd', 'abcd' )
1870: 2c 20 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 31 , ForceAsNull( 1
1880: 2c 20 31 29 2c 20 46 6f 72 63 65 41 73 4e 75 6c , 1), ForceAsNul
1890: 6c 28 20 31 2e 31 2c 20 31 20 29 3b 0d 0a 3c 2f l( 1.1, 1 );..</
18a0: 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c verbatim>..<tabl
18b0: 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c e border="1" cel
18c0: 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c lspacing="4" cel
18d0: 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c lpadding="4">..<
18e0: 74 72 3e 3c 74 68 3e 46 6f 72 63 65 41 73 4e 75 tr><th>ForceAsNu
18f0: 6c 6c 28 20 27 61 27 2c 20 27 62 27 20 29 3c 2f ll( 'a', 'b' )</
1900: 74 68 3e 3c 74 68 3e 46 6f 72 63 65 41 73 4e 75 th><th>ForceAsNu
1910: 6c 6c 28 20 27 61 62 63 64 27 2c 20 27 61 62 63 ll( 'abcd', 'abc
1920: 64 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 46 6f 72 d' )</th><th>For
1930: 63 65 41 73 4e 75 6c 6c 28 20 31 2c 20 31 29 3c ceAsNull( 1, 1)<
1940: 2f 74 68 3e 3c 74 68 3e 46 6f 72 63 65 41 73 4e /th><th>ForceAsN
1950: 75 6c 6c 28 20 31 2e 31 2c 20 2d 39 39 39 39 20 ull( 1.1, -9999
1960: 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 )</th></tr>..<tr
1970: 3e 3c 74 64 3e 61 3c 2f 74 64 3e 3c 74 64 3e 4e ><td>a</td><td>N
1980: 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c ULL</td><td>NULL
1990: 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 </td><td align="
19a0: 72 69 67 68 74 22 3e 31 2e 31 3c 2f 74 64 3e 3c right">1.1</td><
19b0: 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e /tr></table><br>
19c0: 0d 0a 54 68 65 20 3c 62 3e 46 6f 72 63 65 41 73 ..The <b>ForceAs
19d0: 4e 75 6c 6c 28 29 3c 2f 62 3e 20 53 51 4c 20 66 Null()</b> SQL f
19e0: 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 65 76 61 unction will eva
19f0: 6c 75 61 74 65 20 74 77 6f 20 61 72 62 69 74 72 luate two arbitr
1a00: 61 72 79 20 61 72 67 75 6d 65 6e 74 73 2e 3c 62 ary arguments.<b
1a10: 72 3e 0d 0a 49 66 20 74 68 65 79 20 61 72 65 20 r>..If they are
1a20: 65 71 75 61 6c 20 61 6e 64 20 65 78 61 63 74 65 equal and exacte
1a30: 6c 79 20 6f 66 20 74 68 65 20 73 61 6d 65 20 64 ly of the same d
1a40: 61 74 61 2d 74 79 70 65 20 4e 55 4c 4c 20 77 69 ata-type NULL wi
1a50: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 3b 20 ll be returned;
1a60: 6f 74 68 65 72 77 69 73 65 20 74 68 65 20 66 69 otherwise the fi
1a70: 72 73 74 20 61 72 67 75 6d 65 6e 74 20 76 61 6c rst argument val
1a80: 75 65 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 ue will be retur
1a90: 6e 65 64 2e 3c 62 72 3e 0d 0a 55 73 65 66 75 6c ned.<br>..Useful
1aa0: 20 65 2e 67 2e 20 77 68 69 6c 65 20 70 72 6f 63 e.g. while proc
1ab0: 65 73 73 69 6e 67 20 64 61 74 61 20 69 6d 70 6f essing data impo
1ac0: 72 74 65 64 20 66 72 6f 6d 20 61 6e 79 20 3c 62 rted from any <b
1ad0: 3e 53 68 61 70 65 66 69 6c 65 3c 2f 62 3e 20 6f >Shapefile</b> o
1ae0: 72 20 3c 62 3e 44 42 46 20 66 69 6c 65 3c 2f 62 r <b>DBF file</b
1af0: 3e 20 28 73 75 63 68 20 66 6f 72 6d 61 74 73 20 > (such formats
1b00: 64 6f 65 73 6e 27 74 20 73 75 70 70 6f 72 74 20 doesn't support
1b10: 61 6e 79 20 72 65 61 6c 20 4e 55 4c 4c 20 76 61 any real NULL va
1b20: 6c 75 65 2c 20 6f 66 74 65 6e 20 62 65 69 6e 67 lue, often being
1b30: 20 72 65 70 6c 61 63 65 64 20 62 79 20 73 6f 6d replaced by som
1b40: 65 20 63 6f 6e 76 65 6e 74 69 6f 6e 61 6c 20 76 e conventional v
1b50: 61 6c 75 65 20 65 2e 67 2e 20 3c 62 3e 30 3c 2f alue e.g. <b>0</
1b60: 62 3e 20 6f 72 20 3c 62 3e 2d 39 39 39 39 3c 2f b> or <b>-9999</
1b70: 62 3e 20 61 6e 64 20 61 6c 69 6b 65 29 2e 0d 0a b> and alike)...
1b80: 3c 68 72 3e 0d 0a 3c 68 33 3e 47 65 6e 65 72 69 <hr>..<h3>Generi
1b90: 63 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 2d c SQL function -
1ba0: 20 55 55 49 44 20 67 65 6e 65 72 61 74 6f 72 3c UUID generator<
1bb0: 2f 68 33 3e 0d 0a 41 6e 20 3c 61 20 68 72 65 66 /h3>..An <a href
1bc0: 3d 22 68 74 74 70 3a 2f 2f 65 6e 2e 77 69 6b 69 ="http://en.wiki
1bd0: 70 65 64 69 61 2e 6f 72 67 2f 77 69 6b 69 2f 55 pedia.org/wiki/U
1be0: 6e 69 76 65 72 73 61 6c 6c 79 5f 75 6e 69 71 75 niversally_uniqu
1bf0: 65 5f 69 64 65 6e 74 69 66 69 65 72 22 3e 55 6e e_identifier">Un
1c00: 69 76 65 72 73 61 6c 6c 79 20 75 6e 69 71 75 65 iversally unique
1c10: 20 69 64 65 6e 74 69 66 69 65 72 3c 2f 61 3e 20 identifier</a>
1c20: 28 61 6b 61 20 3c 62 3e 55 55 49 44 3c 2f 62 3e (aka <b>UUID</b>
1c30: 29 20 73 69 6d 70 6c 79 20 69 73 20 61 20 3c 75 ) simply is a <u
1c40: 3e 31 32 38 20 62 69 74 3c 2f 75 3e 20 49 6e 74 >128 bit</u> Int
1c50: 65 67 65 72 3b 20 61 63 63 6f 72 64 69 6e 67 6c eger; accordingl
1c60: 79 20 74 6f 20 74 68 65 6f 72 79 2c 20 74 68 65 y to theory, the
1c70: 20 70 72 6f 62 61 62 69 6c 69 74 79 20 74 68 61 probability tha
1c80: 74 20 74 77 6f 20 72 61 6e 64 6f 6d 6c 79 20 67 t two randomly g
1c90: 65 6e 65 72 61 74 65 64 20 55 55 49 44 73 20 63 enerated UUIDs c
1ca0: 6f 75 6c 64 20 61 73 73 75 6d 65 20 74 68 65 20 ould assume the
1cb0: 73 61 6d 65 20 76 61 6c 75 65 20 69 73 20 70 72 same value is pr
1cc0: 61 63 74 69 63 61 6c 6c 79 20 6e 65 61 72 20 7a actically near z
1cd0: 65 72 6f 2e 20 41 6e 64 20 63 6f 6e 73 65 71 75 ero. And consequ
1ce0: 65 6e 74 6c 79 20 55 55 49 44 73 20 61 72 65 20 ently UUIDs are
1cf0: 77 69 64 65 6c 79 20 75 73 65 64 20 61 73 20 3c widely used as <
1d00: 75 3e 75 6e 69 76 65 72 73 61 6c 6c 79 20 75 6e u>universally un
1d10: 69 71 75 65 20 49 44 73 3c 2f 75 3e 2e 3c 62 72 ique IDs</u>.<br
1d20: 3e 0d 0a 55 73 75 61 6c 6c 79 20 55 55 49 44 73 >..Usually UUIDs
1d30: 20 61 72 65 20 72 65 70 72 65 73 65 6e 74 65 64 are represented
1d40: 20 69 6e 20 74 68 65 69 72 20 3c 75 3e 63 61 6e in their <u>can
1d50: 6f 6e 69 63 61 6c 20 66 6f 72 6d 3c 2f 75 3e 2c onical form</u>,
1d60: 20 69 2e 65 2e 20 61 73 20 61 20 73 65 71 75 65 i.e. as a seque
1d70: 6e 63 65 20 6f 66 20 33 32 20 68 65 78 61 64 65 nce of 32 hexade
1d80: 63 69 6d 61 6c 20 64 69 67 69 74 73 20 73 65 70 cimal digits sep
1d90: 61 72 65 74 65 64 20 69 6e 74 6f 20 66 69 76 65 areted into five
1da0: 20 64 69 73 74 69 6e 63 74 20 62 6c 6f 63 6b 2c distinct block,
1db0: 20 61 63 63 6f 72 64 69 6e 67 6c 79 20 74 6f 20 accordingly to
1dc0: 61 20 3c 62 3e 38 2d 34 2d 34 2d 34 2d 31 32 3c a <b>8-4-4-4-12<
1dd0: 2f 62 3e 20 73 63 68 65 6d 61 2e 0d 0a 3c 76 65 /b> schema...<ve
1de0: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 rbatim>..SELECT
1df0: 43 72 65 61 74 65 55 55 49 44 28 29 3b 0d 0a 2d CreateUUID();..-
1e00: 2d 2d 2d 2d 2d 2d 2d 0d 0a 66 66 66 35 66 61 66 -------..fff5faf
1e10: 31 2d 64 63 63 30 2d 34 33 39 31 2d 38 30 35 34 1-dcc0-4391-8054
1e20: 2d 36 65 37 64 65 37 35 64 38 35 62 31 0d 0a 3c -6e7de75d85b1..<
1e30: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20 /verbatim>..The
1e40: 3c 62 3e 43 72 65 61 74 65 55 55 49 44 28 29 3c <b>CreateUUID()<
1e50: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e /b> SQL function
1e60: 20 69 73 20 62 75 69 6c 74 20 6f 6e 20 74 68 65 is built on the
1e70: 20 74 6f 70 20 74 68 65 20 3c 69 3e 48 69 67 68 top the <i>High
1e80: 20 51 75 61 6c 69 74 79 20 50 73 65 75 64 6f 2d Quality Pseudo-
1e90: 52 61 6e 64 6f 6d 20 4e 75 6d 62 65 72 20 47 65 Random Number Ge
1ea0: 6e 65 72 61 74 6f 72 3c 2f 69 3e 20 3c 61 20 68 nerator</i> <a h
1eb0: 72 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e ref="http://www.
1ec0: 73 71 6c 69 74 65 2e 6f 72 67 2f 63 33 72 65 66 sqlite.org/c3ref
1ed0: 2f 72 61 6e 64 6f 6d 6e 65 73 73 2e 68 74 6d 6c /randomness.html
1ee0: 22 3e 69 6e 74 65 72 6e 61 6c 6c 79 20 69 6d 70 ">internally imp
1ef0: 6c 65 6d 65 6e 74 65 64 3c 2f 61 3e 20 62 79 20 lemented</a> by
1f00: 53 51 4c 69 74 65 2e 3c 62 72 3e 0d 0a 54 68 65 SQLite.<br>..The
1f10: 20 72 65 74 75 72 6e 65 64 20 55 55 49 44 20 69 returned UUID i
1f20: 73 20 63 6f 6e 66 6f 72 6d 61 6e 74 20 74 6f 20 s conformant to
1f30: 3c 75 3e 56 65 72 73 69 6f 6e 20 34 20 28 72 61 <u>Version 4 (ra
1f40: 6e 64 6f 6d 29 3c 2f 75 3e 20 28 69 2e 65 2e 20 ndom)</u> (i.e.
1f50: 74 68 65 20 66 69 72 73 74 20 64 69 67 69 74 20 the first digit
1f60: 69 6e 74 6f 20 74 68 65 20 74 68 69 72 64 20 62 into the third b
1f70: 6c 6f 63 6b 20 77 69 6c 6c 20 61 6c 77 61 79 73 lock will always
1f80: 20 62 65 20 3c 62 3e 34 3c 2f 62 3e 20 61 6e 64 be <b>4</b> and
1f90: 20 74 68 65 20 66 69 72 73 74 20 64 69 67 69 74 the first digit
1fa0: 20 69 6e 74 6f 20 74 68 65 20 66 6f 75 72 74 68 into the fourth
1fb0: 20 62 6c 6f 63 6b 20 77 69 6c 6c 20 61 6c 77 61 block will alwa
1fc0: 79 73 20 62 65 20 3c 62 3e 38 3c 2f 62 3e 29 2e ys be <b>8</b>).
1fd0: 0d 0a 3c 68 72 3e 0d 0a 62 61 63 6b 20 74 6f 20 ..<hr>..back to
1fe0: 58 6d 6c 42 6c 6f 62 20 3c 61 20 68 72 65 66 3d XmlBlob <a href=
1ff0: 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61 69 "https://www.gai
2000: 61 2d 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c 2f a-gis.it/fossil/
2010: 6c 69 62 73 70 61 74 69 61 6c 69 74 65 2f 77 69 libspatialite/wi
2020: 6b 69 3f 6e 61 6d 65 3d 58 6d 6c 42 6c 6f 62 2b ki?name=XmlBlob+
2030: 61 6e 64 2b 56 69 72 74 75 61 6c 58 50 61 74 68 and+VirtualXPath
2040: 22 3e 6d 61 69 6e 20 70 61 67 65 3c 2f 61 3e 0a ">main page</a>.
2050: 5a 20 65 61 33 36 35 31 38 64 38 32 32 39 64 31 Z ea36518d8229d1
2060: 32 38 66 61 66 36 63 66 38 30 62 37 61 39 34 61 28faf6cf80b7a94a
2070: 36 37 0a 67.