Artifact
6c07bec5b4ee74785cb801a3f92db90d9db3e5b3:
Wiki page
[4.1.0 Changes] by
sandro
2013-03-05 20:22:04.
0000: 44 20 32 30 31 33 2d 30 33 2d 30 35 54 32 30 3a D 2013-03-05T20:
0010: 32 32 3a 30 34 2e 38 38 34 0a 4c 20 34 2e 31 2e 22:04.884.L 4.1.
0020: 30 5c 73 43 68 61 6e 67 65 73 0a 50 20 61 39 30 0\sChanges.P a90
0030: 32 36 62 36 39 62 31 38 64 62 34 38 36 36 34 39 26b69b18db486649
0040: 30 38 62 62 35 64 38 35 63 33 36 33 36 38 38 37 08bb5d85c3636887
0050: 66 63 65 39 63 0a 55 20 73 61 6e 64 72 6f 0a 57 fce9c.U sandro.W
0060: 20 38 33 31 37 0a 62 61 63 6b 20 74 6f 20 58 6d 8317.back to Xm
0070: 6c 42 6c 6f 62 20 3c 61 20 68 72 65 66 3d 22 68 lBlob <a href="h
0080: 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61 69 61 2d ttps://www.gaia-
0090: 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c 69 gis.it/fossil/li
00a0: 62 73 70 61 74 69 61 6c 69 74 65 2f 77 69 6b 69 bspatialite/wiki
00b0: 3f 6e 61 6d 65 3d 58 6d 6c 42 6c 6f 62 2b 61 6e ?name=XmlBlob+an
00c0: 64 2b 56 69 72 74 75 61 6c 58 50 61 74 68 22 3e d+VirtualXPath">
00d0: 6d 61 69 6e 20 70 61 67 65 3c 2f 61 3e 0d 0a 3c main page</a>..<
00e0: 68 32 3e 4e 65 77 20 53 51 4c 20 66 75 6e 63 74 h2>New SQL funct
00f0: 69 6f 6e 73 20 69 6e 74 72 6f 64 75 63 65 64 20 ions introduced
0100: 69 6e 20 34 2e 31 2e 30 3c 2f 68 32 3e 0d 0a 3c in 4.1.0</h2>..<
0110: 68 33 3e 47 65 6e 65 72 69 63 20 53 51 4c 20 66 h3>Generic SQL f
0120: 75 6e 63 74 69 6f 6e 73 20 2d 20 74 79 70 65 20 unctions - type
0130: 63 61 73 74 69 6e 67 3c 2f 68 33 3e 0d 0a 53 51 casting</h3>..SQ
0140: 4c 69 74 65 20 6f 66 66 65 72 73 20 6a 75 73 74 Lite offers just
0150: 20 61 20 76 65 72 79 20 62 61 73 69 63 20 74 79 a very basic ty
0160: 70 65 20 63 68 65 63 6b 69 6e 67 3b 20 74 68 69 pe checking; thi
0170: 73 20 69 73 20 73 6f 6d 65 74 69 6d 65 73 20 75 s is sometimes u
0180: 73 65 66 75 6c 2c 20 62 75 74 20 63 6f 75 6c 64 seful, but could
0190: 20 62 65 20 72 65 61 6c 6c 79 20 65 6e 6e 6f 79 be really ennoy
01a0: 69 6e 67 20 76 65 72 79 20 6f 66 74 65 6e 2e 3c ing very often.<
01b0: 62 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d br>..<verbatim>.
01c0: 0a 53 45 4c 45 43 54 20 27 31 27 2c 20 54 79 70 .SELECT '1', Typ
01d0: 65 4f 66 28 20 27 31 27 20 29 2c 20 43 41 53 54 eOf( '1' ), CAST
01e0: 20 28 20 27 31 27 20 41 53 20 49 4e 54 45 47 45 ( '1' AS INTEGE
01f0: 52 20 29 2c 20 54 79 70 65 4f 66 28 20 43 41 53 R ), TypeOf( CAS
0200: 54 20 28 20 27 31 27 20 41 53 20 49 4e 54 45 47 T ( '1' AS INTEG
0210: 45 52 20 29 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 ER ) );..</verba
0220: 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 tim>..<table bor
0230: 64 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 der="1" cellspac
0240: 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 ing="4" cellpadd
0250: 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 ing="4">..<tr><t
0260: 68 3e 27 31 27 3c 2f 74 68 3e 3c 74 68 3e 54 79 h>'1'</th><th>Ty
0270: 70 65 4f 66 28 20 27 31 27 20 29 3c 2f 74 68 3e peOf( '1' )</th>
0280: 3c 74 68 3e 43 41 53 54 20 28 20 27 31 27 20 41 <th>CAST ( '1' A
0290: 53 20 49 4e 54 45 47 45 52 20 29 3c 2f 74 68 3e S INTEGER )</th>
02a0: 3c 74 68 3e 54 79 70 65 4f 66 28 20 43 41 53 54 <th>TypeOf( CAST
02b0: 20 28 20 27 31 27 20 41 53 20 49 4e 54 45 47 45 ( '1' AS INTEGE
02c0: 52 20 29 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d R ) )</th></tr>.
02d0: 0a 3c 74 72 3e 3c 74 64 3e 31 3c 2f 74 64 3e 3c .<tr><td>1</td><
02e0: 74 64 3e 74 65 78 74 3c 2f 74 64 3e 3c 74 64 20 td>text</td><td
02f0: 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 3c align="right">1<
0300: 2f 74 64 3e 3c 74 64 3e 69 6e 74 65 67 65 72 3c /td><td>integer<
0310: 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 /td></tr></table
0320: 3e 3c 62 72 3e 0d 0a 54 68 65 20 53 51 4c 20 3c ><br>..The SQL <
0330: 62 3e 43 41 53 54 3c 2f 62 3e 20 6f 70 65 72 61 b>CAST</b> opera
0340: 74 6f 72 20 61 6c 72 65 61 64 79 20 73 75 70 70 tor already supp
0350: 6f 72 74 73 20 74 68 65 20 70 6f 73 73 69 62 69 orts the possibi
0360: 6c 69 74 79 20 74 6f 20 65 78 70 6c 69 63 69 74 lity to explicit
0370: 6c 79 20 73 65 74 20 61 20 64 61 74 61 2d 74 79 ly set a data-ty
0380: 70 65 3b 20 6e 6f 77 20 73 74 61 72 74 69 6e 67 pe; now starting
0390: 20 73 69 6e 63 65 20 34 2e 31 2e 30 20 53 70 61 since 4.1.0 Spa
03a0: 74 69 61 4c 69 74 65 20 73 75 70 70 6f 72 74 73 tiaLite supports
03b0: 20 66 65 77 20 53 51 4c 20 66 75 6e 63 74 69 6f few SQL functio
03c0: 6e 73 20 70 65 72 66 6f 72 6d 69 6e 67 20 74 68 ns performing th
03d0: 65 20 73 61 6d 65 20 74 61 73 6b 2e 3c 62 72 3e e same task.<br>
03e0: 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 ..<u>Please note
03f0: 3c 2f 75 3e 3a 20 73 6f 6d 65 20 73 75 62 74 6c </u>: some subtl
0400: 65 20 64 69 66 66 65 72 65 6e 63 65 73 20 65 78 e differences ex
0410: 69 73 74 73 20 68 65 72 65 20 61 6e 64 20 74 68 ists here and th
0420: 65 72 65 3b 20 70 6c 65 61 73 65 20 63 61 72 65 ere; please care
0430: 66 75 6c 6c 79 20 72 65 61 64 20 74 68 69 73 20 fully read this
0440: 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 70 61 documentation pa
0450: 67 65 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d ge...<verbatim>.
0460: 0a 53 45 4c 45 43 54 20 43 61 73 74 54 6f 49 6e .SELECT CastToIn
0470: 74 65 67 65 72 28 20 31 20 29 2c 20 43 61 73 74 teger( 1 ), Cast
0480: 54 6f 49 6e 74 65 67 65 72 28 20 31 2e 34 20 29 ToInteger( 1.4 )
0490: 2c 20 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 , CastToInteger(
04a0: 20 31 2e 36 20 29 2c 20 0d 0a 20 20 20 20 43 61 1.6 ), .. Ca
04b0: 73 74 54 6f 49 6e 74 65 67 65 72 28 20 27 31 32 stToInteger( '12
04c0: 33 27 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 65 3' ), CastToInte
04d0: 67 65 72 28 20 27 61 6c 70 68 61 27 20 29 2c 20 ger( 'alpha' ),
04e0: 43 61 73 74 54 6f 49 6e 74 65 67 65 72 20 28 20 CastToInteger (
04f0: 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3b 0d 0a zeroblob(4) );..
0500: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 </verbatim>..<ta
0510: 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 ble border="1" c
0520: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 ellspacing="4" c
0530: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d ellpadding="4">.
0540: 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 6f 49 .<tr><th>CastToI
0550: 6e 74 65 67 65 72 28 20 31 20 29 3c 2f 74 68 3e nteger( 1 )</th>
0560: 3c 74 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 <th>CastToIntege
0570: 72 28 20 31 2e 34 20 29 3c 2f 74 68 3e 3c 74 68 r( 1.4 )</th><th
0580: 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20 >CastToInteger(
0590: 31 2e 36 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 1.6 )</th><th>Ca
05a0: 73 74 54 6f 49 6e 74 65 67 65 72 28 20 27 31 32 stToInteger( '12
05b0: 33 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 3' )</th><th>Cas
05c0: 74 54 6f 49 6e 74 65 67 65 72 28 20 27 61 6c 70 tToInteger( 'alp
05d0: 68 61 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 ha' )</th><th>Ca
05e0: 73 74 54 6f 49 6e 74 65 67 65 72 20 28 20 7a 65 stToInteger ( ze
05f0: 72 6f 62 6c 6f 62 28 34 29 20 29 3c 2f 74 68 3e roblob(4) )</th>
0600: 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 20 61 </tr>..<tr><td a
0610: 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 3c 2f lign="right">1</
0620: 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 td><td align="ri
0630: 67 68 74 22 3e 31 3c 2f 74 64 3e 3c 74 64 20 61 ght">1</td><td a
0640: 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 32 3c 2f lign="right">2</
0650: 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 td><td align="ri
0660: 67 68 74 22 3e 31 32 33 3c 2f 74 64 3e 3c 74 64 ght">123</td><td
0670: 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 >NULL</td><td>NU
0680: 4c 4c 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 LL</td></tr></ta
0690: 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 ble><br>..The <b
06a0: 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 29 >CastToInteger()
06b0: 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f </b> SQL functio
06c0: 6e 20 77 69 6c 6c 20 61 74 74 65 6d 70 74 20 74 n will attempt t
06d0: 6f 20 72 65 74 75 72 6e 20 61 20 76 61 6c 75 65 o return a value
06e0: 20 6f 66 20 74 68 65 20 3c 62 3e 49 6e 74 65 67 of the <b>Integ
06f0: 65 72 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70 65 er</b> data-type
0700: 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e , or <b>NULL</b>
0710: 20 69 66 20 6e 6f 20 63 6f 6e 76 65 72 73 69 6f if no conversio
0720: 6e 20 69 73 20 70 6f 73 73 69 62 6c 65 2e 0d 0a n is possible...
0730: 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74 <ul>..<li>an Int
0740: 65 67 65 72 20 69 6e 70 75 74 20 61 72 67 75 6d eger input argum
0750: 65 6e 74 20 77 69 6c 6c 20 62 65 20 72 65 74 75 ent will be retu
0760: 72 6e 65 64 20 61 62 73 6f 6c 75 74 65 6c 79 20 rned absolutely
0770: 75 6e 61 66 66 65 63 74 65 64 2e 3c 2f 6c 69 3e unaffected.</li>
0780: 0d 0a 3c 6c 69 3e 61 20 44 6f 75 62 6c 65 20 69 ..<li>a Double i
0790: 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 nput argument wi
07a0: 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 20 3c 75 ll return the <u
07b0: 3e 6e 65 61 72 65 73 74 3c 2f 75 3e 20 49 6e 74 >nearest</u> Int
07c0: 65 67 65 72 20 76 61 6c 75 65 20 28 61 66 74 65 eger value (afte
07d0: 72 20 61 70 70 6c 79 69 6e 67 20 3c 62 3e 34 2f r applying <b>4/
07e0: 35 3c 2f 62 3e 20 72 6f 75 6e 64 69 6e 67 29 2e 5</b> rounding).
07f0: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 54 65 78 </li>..<li>a Tex
0800: 74 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 t input argument
0810: 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 will return the
0820: 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 49 corresponding I
0830: 6e 74 65 67 65 72 20 76 61 6c 75 65 20 6f 6e 6c nteger value onl
0840: 79 20 69 66 20 74 68 65 20 74 65 78 74 20 73 74 y if the text st
0850: 72 69 6e 67 20 72 65 70 72 65 73 65 6e 74 73 20 ring represents
0860: 61 20 76 61 6c 69 64 20 6e 75 6d 62 65 72 20 28 a valid number (
0870: 65 76 65 6e 20 61 20 64 65 63 69 6d 61 6c 20 6f even a decimal o
0880: 6e 65 29 3a 20 69 66 20 74 68 65 20 74 65 78 74 ne): if the text
0890: 20 73 74 72 69 6e 67 20 63 61 6e 6e 6f 74 20 62 string cannot b
08a0: 65 20 63 6f 6e 76 65 72 74 65 64 20 74 6f 20 61 e converted to a
08b0: 20 6e 75 6d 62 65 72 20 4e 55 4c 4c 20 77 69 6c number NULL wil
08c0: 6c 20 62 65 20 72 65 74 75 72 6e 65 64 2e 3c 2f l be returned.</
08d0: 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 42 4c 4f li>..<li>any BLO
08e0: 42 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 B input argument
08f0: 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e will return a N
0900: 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d ULL value.</li>.
0910: 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c 20 69 6e .<li>any NULL in
0920: 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c put argument wil
0930: 6c 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 l return a NULL
0940: 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 value.</li>..</u
0950: 6c 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 l>..<hr>..<verba
0960: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 61 73 tim>..SELECT Cas
0970: 74 54 6f 44 6f 75 62 6c 65 28 20 31 20 29 2c 20 tToDouble( 1 ),
0980: 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20 31 2e CastToDouble( 1.
0990: 32 33 20 29 2c 20 43 61 73 74 54 6f 44 6f 75 62 23 ), CastToDoub
09a0: 6c 65 28 20 27 31 32 33 2e 34 35 27 20 29 2c 0d le( '123.45' ),.
09b0: 0a 20 20 20 20 43 61 73 74 54 6f 44 6f 75 62 6c . CastToDoubl
09c0: 65 28 20 27 61 6c 70 68 61 27 20 29 2c 20 43 61 e( 'alpha' ), Ca
09d0: 73 74 54 6f 44 6f 75 62 6c 65 20 28 20 7a 65 72 stToDouble ( zer
09e0: 6f 62 6c 6f 62 28 34 29 20 29 3b 0d 0a 3c 2f 76 oblob(4) );..</v
09f0: 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 erbatim>..<table
0a00: 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c 6c border="1" cell
0a10: 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c spacing="4" cell
0a20: 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 padding="4">..<t
0a30: 72 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 r><th>CastToDoub
0a40: 6c 65 28 20 31 20 29 3c 2f 74 68 3e 3c 74 68 3e le( 1 )</th><th>
0a50: 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20 31 2e CastToDouble( 1.
0a60: 32 33 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 23 )</th><th>Cas
0a70: 74 54 6f 44 6f 75 62 6c 65 28 20 27 31 32 33 2e tToDouble( '123.
0a80: 34 35 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 45' )</th><th>Ca
0a90: 73 74 54 6f 44 6f 75 62 6c 65 28 20 27 61 6c 70 stToDouble( 'alp
0aa0: 68 61 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 ha' )</th><th>Ca
0ab0: 73 74 54 6f 44 6f 75 62 6c 65 20 28 20 7a 65 72 stToDouble ( zer
0ac0: 6f 62 6c 6f 62 28 34 29 20 29 3c 2f 74 68 3e 3c oblob(4) )</th><
0ad0: 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 20 61 6c /tr>..<tr><td al
0ae0: 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 2e 30 30 ign="right">1.00
0af0: 30 30 30 30 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 0000</td><td ali
0b00: 67 6e 3d 22 72 69 67 68 74 22 3e 31 2e 32 33 30 gn="right">1.230
0b10: 30 30 30 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 000</td><td alig
0b20: 6e 3d 22 72 69 67 68 74 22 3e 31 32 33 2e 34 35 n="right">123.45
0b30: 30 30 30 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 000</td><td>NULL
0b40: 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 </td><td>NULL</t
0b50: 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c d></tr></table><
0b60: 62 72 3e 0d 0a 54 68 65 20 3c 62 3e 43 61 73 74 br>..The <b>Cast
0b70: 54 6f 44 6f 75 62 6c 65 28 29 3c 2f 62 3e 20 53 ToDouble()</b> S
0b80: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c QL function will
0b90: 20 61 74 74 65 6d 70 74 20 74 6f 20 72 65 74 75 attempt to retu
0ba0: 72 6e 20 61 20 76 61 6c 75 65 20 6f 66 20 74 68 rn a value of th
0bb0: 65 20 3c 62 3e 44 6f 75 62 6c 65 3c 2f 62 3e 20 e <b>Double</b>
0bc0: 64 61 74 61 2d 74 79 70 65 2c 20 6f 72 20 3c 62 data-type, or <b
0bd0: 3e 4e 55 4c 4c 3c 2f 62 3e 20 69 66 20 6e 6f 20 >NULL</b> if no
0be0: 63 6f 6e 76 65 72 73 69 6f 6e 20 69 73 20 70 6f conversion is po
0bf0: 73 73 69 62 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c ssible...<ul>..<
0c00: 6c 69 3e 61 6e 20 49 6e 74 65 67 65 72 20 69 6e li>an Integer in
0c10: 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c put argument wil
0c20: 6c 20 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 l return the cor
0c30: 72 65 73 70 6f 6e 64 69 6e 67 20 44 6f 75 62 6c responding Doubl
0c40: 65 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c e value.</li>..<
0c50: 6c 69 3e 61 20 44 6f 75 62 6c 65 20 69 6e 70 75 li>a Double inpu
0c60: 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 t argument will
0c70: 62 65 20 72 65 74 75 72 6e 65 64 20 61 62 73 6f be returned abso
0c80: 6c 75 74 65 6c 79 20 75 6e 61 66 66 65 63 74 65 lutely unaffecte
0c90: 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 54 d.</li>..<li>a T
0ca0: 65 78 74 20 69 6e 70 75 74 20 61 72 67 75 6d 65 ext input argume
0cb0: 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 nt will return t
0cc0: 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 he corresponding
0cd0: 20 44 6f 75 62 6c 65 20 76 61 6c 75 65 20 6f 6e Double value on
0ce0: 6c 79 20 69 66 20 74 68 65 20 74 65 78 74 20 73 ly if the text s
0cf0: 74 72 69 6e 67 20 72 65 70 72 65 73 65 6e 74 73 tring represents
0d00: 20 61 20 76 61 6c 69 64 20 6e 75 6d 62 65 72 3a a valid number:
0d10: 20 69 66 20 74 68 65 20 74 65 78 74 20 73 74 72 if the text str
0d20: 69 6e 67 20 63 61 6e 6e 6f 74 20 62 65 20 63 6f ing cannot be co
0d30: 6e 76 65 72 74 65 64 20 74 6f 20 61 20 6e 75 6d nverted to a num
0d40: 62 65 72 20 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 ber NULL will be
0d50: 20 72 65 74 75 72 6e 65 64 2e 3c 2f 6c 69 3e 0d returned.</li>.
0d60: 0a 3c 6c 69 3e 61 6e 79 20 42 4c 4f 42 20 69 6e .<li>any BLOB in
0d70: 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c put argument wil
0d80: 6c 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 l return a NULL
0d90: 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 value.</li>..<li
0da0: 3e 61 6e 79 20 4e 55 4c 4c 20 69 6e 70 75 74 20 >any NULL input
0db0: 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 argument will re
0dc0: 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75 turn a NULL valu
0dd0: 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a e.</li>..</ul>..
0de0: 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e <hr>..<verbatim>
0df0: 0d 0a 53 45 4c 45 43 54 20 43 61 73 74 54 6f 54 ..SELECT CastToT
0e00: 65 78 74 28 20 31 20 29 2c 20 43 61 73 74 54 6f ext( 1 ), CastTo
0e10: 54 65 78 74 28 20 31 2e 35 20 29 2c 20 43 61 73 Text( 1.5 ), Cas
0e20: 74 54 6f 54 65 78 74 28 20 27 61 6c 70 68 61 27 tToText( 'alpha'
0e30: 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 20 28 ), CastToText (
0e40: 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3b 0d zeroblob(4) );.
0e50: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 .</verbatim>..<t
0e60: 61 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 able border="1"
0e70: 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 cellspacing="4"
0e80: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e cellpadding="4">
0e90: 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 6f ..<tr><th>CastTo
0ea0: 54 65 78 74 28 20 31 20 29 3c 2f 74 68 3e 3c 74 Text( 1 )</th><t
0eb0: 68 3e 43 61 73 74 54 6f 54 65 78 74 28 20 31 2e h>CastToText( 1.
0ec0: 35 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 5 )</th><th>Cast
0ed0: 54 6f 54 65 78 74 28 20 27 61 6c 70 68 61 27 20 ToText( 'alpha'
0ee0: 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f )</th><th>CastTo
0ef0: 54 65 78 74 20 28 20 7a 65 72 6f 62 6c 6f 62 28 Text ( zeroblob(
0f00: 34 29 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 4) )</th></tr>..
0f10: 3c 74 72 3e 3c 74 64 3e 31 3c 2f 74 64 3e 3c 74 <tr><td>1</td><t
0f20: 64 3e 31 2e 35 3c 2f 74 64 3e 3c 74 64 3e 61 6c d>1.5</td><td>al
0f30: 70 68 61 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c pha</td><td>NULL
0f40: 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c </td></tr></tabl
0f50: 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 3e 43 e><br>..The <b>C
0f60: 61 73 74 54 6f 54 65 78 74 28 29 3c 2f 62 3e 20 astToText()</b>
0f70: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c SQL function wil
0f80: 6c 20 61 74 74 65 6d 70 74 20 74 6f 20 72 65 74 l attempt to ret
0f90: 75 72 6e 20 61 20 76 61 6c 75 65 20 6f 66 20 74 urn a value of t
0fa0: 68 65 20 3c 62 3e 54 65 78 74 3c 2f 62 3e 20 64 he <b>Text</b> d
0fb0: 61 74 61 2d 74 79 70 65 2c 20 6f 72 20 3c 62 3e ata-type, or <b>
0fc0: 4e 55 4c 4c 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 NULL</b> if no c
0fd0: 6f 6e 76 65 72 73 69 6f 6e 20 69 73 20 70 6f 73 onversion is pos
0fe0: 73 69 62 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c sible...<ul>..<l
0ff0: 69 3e 61 6e 20 49 6e 74 65 67 65 72 20 69 6e 70 i>an Integer inp
1000: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c ut argument will
1010: 20 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 72 return the corr
1020: 65 73 70 6f 6e 64 69 6e 67 20 54 65 78 74 20 76 esponding Text v
1030: 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e alue.</li>..<li>
1040: 61 20 44 6f 75 62 6c 65 20 69 6e 70 75 74 20 61 a Double input a
1050: 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 62 65 20 rgument will be
1060: 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 72 65 return the corre
1070: 73 70 6f 6e 64 69 6e 67 20 54 65 78 74 20 76 61 sponding Text va
1080: 6c 75 65 3b 20 6e 6f 20 73 69 67 6e 69 66 69 63 lue; no signific
1090: 61 74 69 76 65 20 64 65 63 69 6d 61 6c 20 64 69 ative decimal di
10a0: 67 69 74 20 77 69 6c 6c 20 62 65 20 73 75 70 70 git will be supp
10b0: 72 65 73 73 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c ressed.</li>..<l
10c0: 69 3e 61 20 54 65 78 74 20 69 6e 70 75 74 20 61 i>a Text input a
10d0: 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 rgument will ret
10e0: 75 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f urn the correspo
10f0: 6e 64 69 6e 67 20 44 6f 75 62 6c 65 20 76 61 6c nding Double val
1100: 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e ue.</li>..<li>an
1110: 79 20 42 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 y BLOB input arg
1120: 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 ument will retur
1130: 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c n a NULL value.<
1140: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 /li>..<li>any NU
1150: 4c 4c 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e LL input argumen
1160: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 t will return a
1170: 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e NULL value.</li>
1180: 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 76 65 72 62 61 74 ..</ul>..<verbat
1190: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 61 73 74 im>..SELECT Cast
11a0: 54 6f 54 65 78 74 28 20 31 2c 20 34 20 29 2c 20 ToText( 1, 4 ),
11b0: 43 61 73 74 54 6f 54 65 78 74 28 20 31 32 33 34 CastToText( 1234
11c0: 2c 20 32 20 29 2c 20 43 61 73 74 54 6f 54 65 78 , 2 ), CastToTex
11d0: 74 28 20 31 2c 20 38 20 29 2c 20 43 61 73 74 54 t( 1, 8 ), CastT
11e0: 6f 54 65 78 74 28 20 31 2e 35 2c 20 34 20 29 3b oText( 1.5, 4 );
11f0: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c ..</verbatim>..<
1200: 74 61 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 table border="1"
1210: 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 cellspacing="4"
1220: 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 cellpadding="4"
1230: 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 >..<tr><th>CastT
1240: 6f 54 65 78 74 28 20 31 2c 20 34 20 29 3c 2f 74 oText( 1, 4 )</t
1250: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 h><th>CastToText
1260: 28 20 31 32 33 34 2c 20 32 20 29 3c 2f 74 68 3e ( 1234, 2 )</th>
1270: 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 28 20 <th>CastToText(
1280: 31 2c 20 38 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 1, 8 )</th><th>C
1290: 61 73 74 54 6f 54 65 78 74 28 20 31 2e 35 2c 20 astToText( 1.5,
12a0: 34 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 4 )</th></tr>..<
12b0: 74 72 3e 3c 74 64 3e 30 30 30 31 3c 2f 74 64 3e tr><td>0001</td>
12c0: 3c 74 64 3e 31 32 33 34 3c 2f 74 64 3e 3c 74 64 <td>1234</td><td
12d0: 3e 30 30 30 30 30 30 30 31 3c 2f 74 64 3e 3c 74 >00000001</td><t
12e0: 64 3e 30 30 30 31 2e 35 3c 2f 74 64 3e 3c 2f 74 d>0001.5</td></t
12f0: 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a r></table><br>..
1300: 41 6e 20 6f 76 65 72 6c 6f 61 64 65 64 20 76 65 An overloaded ve
1310: 72 73 69 6f 6e 20 6f 66 20 3c 62 3e 43 61 73 74 rsion of <b>Cast
1320: 54 6f 54 65 78 74 28 29 3c 2f 62 3e 20 69 73 20 ToText()</b> is
1330: 73 75 70 70 6f 72 74 65 64 20 61 73 20 77 65 6c supported as wel
1340: 6c 2c 20 62 75 74 20 6f 6e 6c 79 20 77 68 65 6e l, but only when
1350: 20 74 68 65 20 69 6e 70 75 74 20 61 72 67 75 6d the input argum
1360: 65 6e 74 20 69 73 20 6f 66 20 74 68 65 20 49 6e ent is of the In
1370: 74 65 67 65 72 20 6f 72 20 44 6f 75 62 6c 65 20 teger or Double
1380: 64 61 74 61 2d 74 79 70 65 3a 20 69 6e 20 74 68 data-type: in th
1390: 69 73 20 63 61 73 65 20 61 20 73 65 63 6f 6e 64 is case a second
13a0: 20 49 6e 74 65 67 65 72 20 61 72 67 75 6d 65 6e Integer argumen
13b0: 74 20 63 6f 75 6c 64 20 62 65 20 6f 70 74 69 6f t could be optio
13c0: 6e 61 6c 6c 79 20 73 70 65 63 69 66 69 65 64 2c nally specified,
13d0: 20 61 6e 64 20 77 69 6c 6c 20 62 65 20 69 6e 74 and will be int
13e0: 65 72 70 72 65 74 65 72 65 64 20 61 64 20 3c 62 erpretered ad <b
13f0: 3e 7a 65 72 6f 2d 70 61 64 64 69 6e 67 2d 6c 65 >zero-padding-le
1400: 6e 67 74 68 3c 2f 62 3e 2e 3c 62 72 3e 0d 0a 69 ngth</b>.<br>..i
1410: 2e 65 2e 20 74 68 65 20 72 65 74 75 72 6e 65 64 .e. the returned
1420: 20 54 65 78 74 20 73 74 72 69 6e 67 20 69 6e 20 Text string in
1430: 74 68 69 73 20 63 61 73 65 20 77 69 6c 6c 20 68 this case will h
1440: 61 76 65 20 61 6e 20 69 6e 74 65 67 65 72 20 70 ave an integer p
1450: 61 72 74 20 61 74 20 6c 65 61 73 74 20 6f 66 20 art at least of
1460: 74 68 65 20 73 70 65 63 69 66 69 65 64 20 6c 65 the specified le
1470: 6e 67 74 68 2c 20 61 6e 64 20 65 76 65 6e 74 75 ngth, and eventu
1480: 61 6c 6c 79 20 70 61 64 64 65 64 20 62 79 20 69 ally padded by i
1490: 6e 73 65 72 74 69 6e 67 20 6e 6f 74 20 73 69 67 nserting not sig
14a0: 6e 69 66 69 63 61 74 69 76 65 20 6c 65 61 64 69 nificative leadi
14b0: 6e 67 20 5a 45 52 4f 65 73 2e 3c 62 72 3e 0d 0a ng ZEROes.<br>..
14c0: 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e <hr>..<verbatim>
14d0: 0d 0a 53 45 4c 45 43 54 20 43 61 73 74 54 6f 42 ..SELECT CastToB
14e0: 6c 6f 62 28 20 31 20 29 2c 20 43 61 73 74 54 6f lob( 1 ), CastTo
14f0: 42 6c 6f 62 28 20 31 2e 35 20 29 2c 20 48 65 78 Blob( 1.5 ), Hex
1500: 28 20 43 61 73 74 54 6f 42 6c 6f 62 28 20 27 61 ( CastToBlob( 'a
1510: 6c 70 68 61 27 20 29 20 29 2c 20 48 65 78 20 28 lpha' ) ), Hex (
1520: 20 43 61 73 74 54 6f 42 6c 6f 62 20 28 20 7a 65 CastToBlob ( ze
1530: 72 6f 62 6c 6f 62 28 34 29 20 29 20 29 3b 0d 0a roblob(4) ) );..
1540: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 </verbatim>..<ta
1550: 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 ble border="1" c
1560: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 ellspacing="4" c
1570: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d ellpadding="4">.
1580: 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 6f 42 .<tr><th>CastToB
1590: 6c 6f 62 28 20 31 20 29 3c 2f 74 68 3e 3c 74 68 lob( 1 )</th><th
15a0: 3e 43 61 73 74 54 6f 42 6c 6f 62 28 20 31 2e 35 >CastToBlob( 1.5
15b0: 20 29 3c 2f 74 68 3e 3c 74 68 3e 48 65 78 28 20 )</th><th>Hex(
15c0: 43 61 73 74 54 6f 42 6c 6f 62 28 20 27 61 6c 70 CastToBlob( 'alp
15d0: 68 61 27 20 29 20 29 3c 2f 74 68 3e 3c 74 68 3e ha' ) )</th><th>
15e0: 48 65 78 28 20 43 61 73 74 54 6f 54 65 78 74 20 Hex( CastToText
15f0: 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 20 ( zeroblob(4) )
1600: 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 )</th></tr>..<tr
1610: 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 ><td>NULL</td><t
1620: 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 36 d>NULL</td><td>6
1630: 31 36 43 37 30 36 38 36 31 3c 2f 74 64 3e 3c 74 16C706861</td><t
1640: 64 3e 30 30 30 30 30 30 30 30 3c 2f 74 64 3e 3c d>00000000</td><
1650: 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e /tr></table><br>
1660: 0d 0a 54 68 65 20 3c 62 3e 43 61 73 74 54 6f 42 ..The <b>CastToB
1670: 6c 6f 62 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 lob()</b> SQL fu
1680: 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 61 74 74 65 nction will atte
1690: 6d 70 74 20 74 6f 20 72 65 74 75 72 6e 20 61 20 mpt to return a
16a0: 76 61 6c 75 65 20 6f 66 20 74 68 65 20 3c 62 3e value of the <b>
16b0: 42 4c 4f 42 3c 2f 62 3e 20 64 61 74 61 2d 74 79 BLOB</b> data-ty
16c0: 70 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c 3c 2f pe, or <b>NULL</
16d0: 62 3e 20 69 66 20 6e 6f 20 63 6f 6e 76 65 72 73 b> if no convers
16e0: 69 6f 6e 20 69 73 20 70 6f 73 73 69 62 6c 65 2e ion is possible.
16f0: 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 ..<ul>..<li>an I
1700: 6e 74 65 67 65 72 20 69 6e 70 75 74 20 61 72 67 nteger input arg
1710: 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 ument will retur
1720: 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c n a NULL value.<
1730: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75 62 /li>..<li>a Doub
1740: 6c 65 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e le input argumen
1750: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 t will return a
1760: 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e NULL value.</li>
1770: 0d 0a 3c 6c 69 3e 61 20 54 65 78 74 20 69 6e 70 ..<li>a Text inp
1780: 75 74 20 61 72 67 75 6d 65 6e 74 20 20 77 69 6c ut argument wil
1790: 6c 20 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 l return the cor
17a0: 72 65 73 70 6f 6e 64 69 6e 67 20 42 4c 4f 42 20 responding BLOB
17b0: 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 value.</li>..<li
17c0: 3e 61 6e 79 20 42 4c 4f 42 20 69 6e 70 75 74 20 >any BLOB input
17d0: 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 argument will re
17e0: 74 75 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 turn the corresp
17f0: 6f 6e 64 69 6e 67 20 42 4c 4f 42 20 76 61 6c 75 onding BLOB valu
1800: 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 e.</li>..<li>any
1810: 20 4e 55 4c 4c 20 69 6e 70 75 74 20 61 72 67 75 NULL input argu
1820: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e ment will return
1830: 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f a NULL value.</
1840: 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 68 72 3e li>..</ul>..<hr>
1850: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 ..<verbatim>..SE
1860: 4c 45 43 54 20 46 6f 72 63 65 41 73 4e 75 6c 6c LECT ForceAsNull
1870: 28 20 27 61 27 2c 20 27 62 27 20 29 2c 20 46 6f ( 'a', 'b' ), Fo
1880: 72 63 65 41 73 4e 75 6c 6c 28 20 27 61 62 63 64 rceAsNull( 'abcd
1890: 27 2c 20 27 61 62 63 64 27 20 29 2c 20 46 6f 72 ', 'abcd' ), For
18a0: 63 65 41 73 4e 75 6c 6c 28 20 31 2c 20 31 29 2c ceAsNull( 1, 1),
18b0: 20 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 31 2e ForceAsNull( 1.
18c0: 31 2c 20 31 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 1, 1 );..</verba
18d0: 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 tim>..<table bor
18e0: 64 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 der="1" cellspac
18f0: 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 ing="4" cellpadd
1900: 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 ing="4">..<tr><t
1910: 68 3e 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 27 h>ForceAsNull( '
1920: 61 27 2c 20 27 62 27 20 29 3c 2f 74 68 3e 3c 74 a', 'b' )</th><t
1930: 68 3e 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 27 h>ForceAsNull( '
1940: 61 62 63 64 27 2c 20 27 61 62 63 64 27 20 29 3c abcd', 'abcd' )<
1950: 2f 74 68 3e 3c 74 68 3e 46 6f 72 63 65 41 73 4e /th><th>ForceAsN
1960: 75 6c 6c 28 20 31 2c 20 31 29 3c 2f 74 68 3e 3c ull( 1, 1)</th><
1970: 74 68 3e 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 th>ForceAsNull(
1980: 31 2e 31 2c 20 2d 39 39 39 39 20 29 3c 2f 74 68 1.1, -9999 )</th
1990: 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e ></tr>..<tr><td>
19a0: 61 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f a</td><td>NULL</
19b0: 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e td><td>NULL</td>
19c0: 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 <td align="right
19d0: 22 3e 31 2e 31 3c 2f 74 64 3e 3c 2f 74 72 3e 3c ">1.1</td></tr><
19e0: 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 /table><br>..The
19f0: 20 3c 62 3e 46 6f 72 63 65 41 73 4e 75 6c 6c 28 <b>ForceAsNull(
1a00: 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 )</b> SQL functi
1a10: 6f 6e 20 77 69 6c 6c 20 65 76 61 6c 75 61 74 65 on will evaluate
1a20: 20 74 77 6f 20 61 72 62 69 74 72 61 72 79 20 61 two arbitrary a
1a30: 72 67 75 6d 65 6e 74 73 2e 3c 62 72 3e 0d 0a 49 rguments.<br>..I
1a40: 66 20 74 68 65 79 20 61 72 65 20 65 71 75 61 6c f they are equal
1a50: 20 61 6e 64 20 65 78 61 63 74 65 6c 79 20 6f 66 and exactely of
1a60: 20 74 68 65 20 73 61 6d 65 20 64 61 74 61 2d 74 the same data-t
1a70: 79 70 65 20 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 ype NULL will be
1a80: 20 72 65 74 75 72 6e 65 64 3b 20 6f 74 68 65 72 returned; other
1a90: 77 69 73 65 20 74 68 65 20 66 69 72 73 74 20 61 wise the first a
1aa0: 72 67 75 6d 65 6e 74 20 76 61 6c 75 65 20 77 69 rgument value wi
1ab0: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 2e 3c ll be returned.<
1ac0: 62 72 3e 0d 0a 55 73 65 66 75 6c 20 65 2e 67 2e br>..Useful e.g.
1ad0: 20 77 68 69 6c 65 20 70 72 6f 63 65 73 73 69 6e while processin
1ae0: 67 20 64 61 74 61 20 69 6d 70 6f 72 74 65 64 20 g data imported
1af0: 66 72 6f 6d 20 61 6e 79 20 3c 62 3e 53 68 61 70 from any <b>Shap
1b00: 65 66 69 6c 65 3c 2f 62 3e 20 6f 72 20 3c 62 3e efile</b> or <b>
1b10: 44 42 46 20 66 69 6c 65 3c 2f 62 3e 20 28 73 75 DBF file</b> (su
1b20: 63 68 20 66 6f 72 6d 61 74 73 20 64 6f 65 73 6e ch formats doesn
1b30: 27 74 20 73 75 70 70 6f 72 74 20 61 6e 79 20 72 't support any r
1b40: 65 61 6c 20 4e 55 4c 4c 20 76 61 6c 75 65 2c 20 eal NULL value,
1b50: 6f 66 74 65 6e 20 62 65 69 6e 67 20 72 65 70 6c often being repl
1b60: 61 63 65 64 20 62 79 20 73 6f 6d 65 20 63 6f 6e aced by some con
1b70: 76 65 6e 74 69 6f 6e 61 6c 20 76 61 6c 75 65 20 ventional value
1b80: 65 2e 67 2e 20 3c 62 3e 30 3c 2f 62 3e 20 6f 72 e.g. <b>0</b> or
1b90: 20 3c 62 3e 2d 39 39 39 39 3c 2f 62 3e 20 61 6e <b>-9999</b> an
1ba0: 64 20 61 6c 69 6b 65 29 2e 0d 0a 3c 68 72 3e 0d d alike)...<hr>.
1bb0: 0a 3c 68 33 3e 47 65 6e 65 72 69 63 20 53 51 4c .<h3>Generic SQL
1bc0: 20 66 75 6e 63 74 69 6f 6e 20 2d 20 55 55 49 44 function - UUID
1bd0: 20 67 65 6e 65 72 61 74 6f 72 3c 2f 68 33 3e 0d generator</h3>.
1be0: 0a 41 6e 20 3c 61 20 68 72 65 66 3d 22 68 74 74 .An <a href="htt
1bf0: 70 3a 2f 2f 65 6e 2e 77 69 6b 69 70 65 64 69 61 p://en.wikipedia
1c00: 2e 6f 72 67 2f 77 69 6b 69 2f 55 6e 69 76 65 72 .org/wiki/Univer
1c10: 73 61 6c 6c 79 5f 75 6e 69 71 75 65 5f 69 64 65 sally_unique_ide
1c20: 6e 74 69 66 69 65 72 22 3e 55 6e 69 76 65 72 73 ntifier">Univers
1c30: 61 6c 6c 79 20 75 6e 69 71 75 65 20 69 64 65 6e ally unique iden
1c40: 74 69 66 69 65 72 3c 2f 61 3e 20 28 61 6b 61 20 tifier</a> (aka
1c50: 3c 62 3e 55 55 49 44 3c 2f 62 3e 29 20 73 69 6d <b>UUID</b>) sim
1c60: 70 6c 79 20 69 73 20 61 20 3c 75 3e 31 32 38 20 ply is a <u>128
1c70: 62 69 74 3c 2f 75 3e 20 49 6e 74 65 67 65 72 3b bit</u> Integer;
1c80: 20 61 63 63 6f 72 64 69 6e 67 6c 79 20 74 6f 20 accordingly to
1c90: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f <a href="http://
1ca0: 65 6e 2e 77 69 6b 69 70 65 64 69 61 2e 6f 72 67 en.wikipedia.org
1cb0: 2f 77 69 6b 69 2f 55 55 49 44 23 52 61 6e 64 6f /wiki/UUID#Rando
1cc0: 6d 5f 55 55 49 44 5f 70 72 6f 62 61 62 69 6c 69 m_UUID_probabili
1cd0: 74 79 5f 6f 66 5f 64 75 70 6c 69 63 61 74 65 73 ty_of_duplicates
1ce0: 22 3e 74 68 65 6f 72 79 3c 2f 61 3e 2c 20 74 68 ">theory</a>, th
1cf0: 65 20 70 72 6f 62 61 62 69 6c 69 74 79 20 74 68 e probability th
1d00: 61 74 20 74 77 6f 20 72 61 6e 64 6f 6d 6c 79 20 at two randomly
1d10: 67 65 6e 65 72 61 74 65 64 20 55 55 49 44 73 20 generated UUIDs
1d20: 63 6f 75 6c 64 20 61 73 73 75 6d 65 20 74 68 65 could assume the
1d30: 20 73 61 6d 65 20 76 61 6c 75 65 20 69 73 20 6e same value is n
1d40: 65 61 72 20 74 6f 20 7a 65 72 6f 20 66 6f 72 20 ear to zero for
1d50: 6d 61 6e 79 20 70 72 61 63 74 69 63 61 6c 20 70 many practical p
1d60: 75 72 70 6f 73 65 73 2e 20 41 6e 64 20 63 6f 6e urposes. And con
1d70: 73 65 71 75 65 6e 74 6c 79 20 55 55 49 44 73 20 sequently UUIDs
1d80: 61 72 65 20 77 69 64 65 6c 79 20 75 73 65 64 20 are widely used
1d90: 61 73 20 3c 75 3e 75 6e 69 76 65 72 73 61 6c 6c as <u>universall
1da0: 79 20 75 6e 69 71 75 65 20 49 44 73 3c 2f 75 3e y unique IDs</u>
1db0: 2e 3c 62 72 3e 0d 0a 55 73 75 61 6c 6c 79 20 55 .<br>..Usually U
1dc0: 55 49 44 73 20 61 72 65 20 72 65 70 72 65 73 65 UIDs are represe
1dd0: 6e 74 65 64 20 69 6e 20 74 68 65 69 72 20 3c 75 nted in their <u
1de0: 3e 63 61 6e 6f 6e 69 63 61 6c 20 66 6f 72 6d 3c >canonical form<
1df0: 2f 75 3e 2c 20 69 2e 65 2e 20 61 73 20 61 20 73 /u>, i.e. as a s
1e00: 65 71 75 65 6e 63 65 20 6f 66 20 33 32 20 68 65 equence of 32 he
1e10: 78 61 64 65 63 69 6d 61 6c 20 64 69 67 69 74 73 xadecimal digits
1e20: 20 73 65 70 61 72 65 74 65 64 20 69 6e 74 6f 20 separeted into
1e30: 66 69 76 65 20 64 69 73 74 69 6e 63 74 20 62 6c five distinct bl
1e40: 6f 63 6b 2c 20 61 63 63 6f 72 64 69 6e 67 6c 79 ock, accordingly
1e50: 20 74 6f 20 61 20 3c 62 3e 38 2d 34 2d 34 2d 34 to a <b>8-4-4-4
1e60: 2d 31 32 3c 2f 62 3e 20 73 63 68 65 6d 61 2e 0d -12</b> schema..
1e70: 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c .<verbatim>..SEL
1e80: 45 43 54 20 43 72 65 61 74 65 55 55 49 44 28 29 ECT CreateUUID()
1e90: 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 66 66 66 ;..--------..fff
1ea0: 35 66 61 66 31 2d 64 63 63 30 2d 34 33 39 31 2d 5faf1-dcc0-4391-
1eb0: 38 30 35 34 2d 36 65 37 64 65 37 35 64 38 35 62 8054-6e7de75d85b
1ec0: 31 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 1..</verbatim>..
1ed0: 54 68 65 20 3c 62 3e 43 72 65 61 74 65 55 55 49 The <b>CreateUUI
1ee0: 44 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 D()</b> SQL func
1ef0: 74 69 6f 6e 20 69 73 20 62 75 69 6c 74 20 6f 6e tion is built on
1f00: 20 74 68 65 20 74 6f 70 20 74 68 65 20 3c 69 3e the top the <i>
1f10: 48 69 67 68 20 51 75 61 6c 69 74 79 20 50 73 65 High Quality Pse
1f20: 75 64 6f 2d 52 61 6e 64 6f 6d 20 4e 75 6d 62 65 udo-Random Numbe
1f30: 72 20 47 65 6e 65 72 61 74 6f 72 3c 2f 69 3e 20 r Generator</i>
1f40: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f <a href="http://
1f50: 77 77 77 2e 73 71 6c 69 74 65 2e 6f 72 67 2f 63 www.sqlite.org/c
1f60: 33 72 65 66 2f 72 61 6e 64 6f 6d 6e 65 73 73 2e 3ref/randomness.
1f70: 68 74 6d 6c 22 3e 69 6e 74 65 72 6e 61 6c 6c 79 html">internally
1f80: 20 69 6d 70 6c 65 6d 65 6e 74 65 64 3c 2f 61 3e implemented</a>
1f90: 20 62 79 20 53 51 4c 69 74 65 2e 3c 62 72 3e 0d by SQLite.<br>.
1fa0: 0a 54 68 65 20 72 65 74 75 72 6e 65 64 20 55 55 .The returned UU
1fb0: 49 44 20 69 73 20 63 6f 6e 66 6f 72 6d 61 6e 74 ID is conformant
1fc0: 20 74 6f 20 3c 75 3e 56 65 72 73 69 6f 6e 20 34 to <u>Version 4
1fd0: 20 28 72 61 6e 64 6f 6d 29 3c 2f 75 3e 20 28 69 (random)</u> (i
1fe0: 2e 65 2e 20 74 68 65 20 66 69 72 73 74 20 64 69 .e. the first di
1ff0: 67 69 74 20 69 6e 74 6f 20 74 68 65 20 74 68 69 git into the thi
2000: 72 64 20 62 6c 6f 63 6b 20 77 69 6c 6c 20 61 6c rd block will al
2010: 77 61 79 73 20 62 65 20 3c 62 3e 34 3c 2f 62 3e ways be <b>4</b>
2020: 20 61 6e 64 20 74 68 65 20 66 69 72 73 74 20 64 and the first d
2030: 69 67 69 74 20 69 6e 74 6f 20 74 68 65 20 66 6f igit into the fo
2040: 75 72 74 68 20 62 6c 6f 63 6b 20 77 69 6c 6c 20 urth block will
2050: 61 6c 77 61 79 73 20 62 65 20 3c 62 3e 38 3c 2f always be <b>8</
2060: 62 3e 29 2e 0d 0a 3c 68 72 3e 0d 0a 62 61 63 6b b>)...<hr>..back
2070: 20 74 6f 20 58 6d 6c 42 6c 6f 62 20 3c 61 20 68 to XmlBlob <a h
2080: 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 ref="https://www
2090: 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 .gaia-gis.it/fos
20a0: 73 69 6c 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 sil/libspatialit
20b0: 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d 58 6d 6c 42 e/wiki?name=XmlB
20c0: 6c 6f 62 2b 61 6e 64 2b 56 69 72 74 75 61 6c 58 lob+and+VirtualX
20d0: 50 61 74 68 22 3e 6d 61 69 6e 20 70 61 67 65 3c Path">main page<
20e0: 2f 61 3e 0a 5a 20 38 61 62 31 32 65 38 39 36 61 /a>.Z 8ab12e896a
20f0: 66 35 34 62 39 37 38 64 61 64 38 39 62 35 63 39 f54b978dad89b5c9
2100: 61 64 38 39 35 30 0a ad8950.