Wiki page
[4.1.0 Changes] by
sandro
2014-08-27 13:03:19.
0000: 44 20 32 30 31 34 2d 30 38 2d 32 37 54 31 33 3a D 2014-08-27T13:
0010: 30 33 3a 31 39 2e 34 35 39 0a 4c 20 34 2e 31 2e 03:19.459.L 4.1.
0020: 30 5c 73 43 68 61 6e 67 65 73 0a 50 20 39 37 62 0\sChanges.P 97b
0030: 64 38 61 37 36 30 34 61 65 37 61 39 64 32 64 38 d8a7604ae7a9d2d8
0040: 31 66 31 64 30 65 30 38 38 33 61 62 34 66 64 61 1f1d0e0883ab4fda
0050: 36 66 62 31 34 0a 55 20 73 61 6e 64 72 6f 0a 57 6fb14.U sandro.W
0060: 20 32 31 33 38 37 0a 3c 61 20 68 72 65 66 3d 22 21387.<a href="
0070: 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61 69 61 https://www.gaia
0080: 2d 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c -gis.it/fossil/l
0090: 69 62 73 70 61 74 69 61 6c 69 74 65 2f 77 69 6b ibspatialite/wik
00a0: 69 3f 6e 61 6d 65 3d 34 2e 32 2e 30 2d 64 6f 63 i?name=4.2.0-doc
00b0: 22 3e 62 61 63 6b 3c 2f 61 3e 0d 0a 3c 68 32 3e ">back</a>..<h2>
00c0: 4e 65 77 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e New SQL function
00d0: 73 20 69 6e 74 72 6f 64 75 63 65 64 20 69 6e 20 s introduced in
00e0: 34 2e 31 2e 30 3c 2f 68 32 3e 0d 0a 54 61 62 6c 4.1.0</h2>..Tabl
00f0: 65 20 6f 66 20 63 6f 6e 74 65 6e 74 73 3a 0d 0a e of contents:..
0100: 3c 75 6c 3e 0d 0a 3c 6c 69 3e 53 51 4c 20 66 75 <ul>..<li>SQL fu
0110: 6e 63 74 69 6f 6e 73 20 73 75 70 70 6f 72 74 69 nctions supporti
0120: 6e 67 20 3c 61 20 68 72 65 66 3d 22 23 63 61 73 ng <a href="#cas
0130: 74 22 3e 64 61 74 61 2d 74 79 70 65 20 63 61 73 t">data-type cas
0140: 74 69 6e 67 3c 2f 61 3e 3c 2f 6c 69 3e 0d 0a 3c ting</a></li>..<
0150: 6c 69 3e 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 li>SQL functions
0160: 20 73 75 70 70 6f 72 74 69 6e 67 20 3c 61 20 68 supporting <a h
0170: 72 65 66 3d 22 23 75 75 69 64 22 3e 55 55 49 44 ref="#uuid">UUID
0180: 20 61 6e 64 20 4d 44 35 3c 2f 61 3e 3c 2f 6c 69 and MD5</a></li
0190: 3e 0d 0a 3c 6c 69 3e 53 70 61 74 69 61 6c 20 53 >..<li>Spatial S
01a0: 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 73 75 70 QL functions sup
01b0: 70 6f 72 74 69 6e 67 20 3c 61 20 68 72 65 66 3d porting <a href=
01c0: 22 23 67 65 6f 6d 22 3e 47 65 6f 6d 65 74 72 69 "#geom">Geometri
01d0: 65 73 3c 2f 61 3e 3c 75 6c 3e 0d 0a 3c 6c 69 3e es</a><ul>..<li>
01e0: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 73 75 SQL functions su
01f0: 70 70 6f 72 74 69 6e 67 20 3c 61 20 68 72 65 66 pporting <a href
0200: 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61 ="https://www.ga
0210: 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c ia-gis.it/fossil
0220: 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 65 2f 77 /libspatialite/w
0230: 69 6b 69 3f 6e 61 6d 65 3d 63 69 72 63 6c 65 73 iki?name=circles
0240: 2d 65 6c 6c 69 70 73 65 73 22 3e 43 69 72 63 6c -ellipses">Circl
0250: 65 73 20 61 6e 64 20 45 6c 6c 69 70 73 65 73 3c es and Ellipses<
0260: 2f 61 3e 3c 2f 6c 69 3e 3c 2f 75 6c 3e 3c 2f 6c /a></li></ul></l
0270: 69 3e 0d 0a 3c 6c 69 3e 53 51 4c 20 66 75 6e 63 i>..<li>SQL func
0280: 74 69 6f 6e 73 20 73 75 70 70 6f 72 74 69 6e 67 tions supporting
0290: 20 3c 61 20 68 72 65 66 3d 22 23 75 6e 73 61 66 <a href="#unsaf
02a0: 65 22 3e 75 6e 73 61 66 65 3c 2f 61 3e 20 64 69 e">unsafe</a> di
02b0: 72 65 63 74 20 49 6d 70 6f 72 74 2f 45 78 70 6f rect Import/Expo
02c0: 72 74 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a rt</li>..</ul>..
02d0: 3c 68 33 3e 3c 61 20 6e 61 6d 65 3d 22 67 65 6e <h3><a name="gen
02e0: 65 72 69 63 22 3e 63 61 73 74 3c 2f 61 3e 20 53 eric">cast</a> S
02f0: 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 2d 20 74 QL functions - t
0300: 79 70 65 20 63 61 73 74 69 6e 67 3c 2f 68 33 3e ype casting</h3>
0310: 0d 0a 53 51 4c 69 74 65 20 6f 66 66 65 72 73 20 ..SQLite offers
0320: 6a 75 73 74 20 61 20 76 65 72 79 20 62 61 73 69 just a very basi
0330: 63 20 74 79 70 65 20 63 68 65 63 6b 69 6e 67 3b c type checking;
0340: 20 74 68 69 73 20 69 73 20 73 6f 6d 65 74 69 6d this is sometim
0350: 65 73 20 75 73 65 66 75 6c 2c 20 62 75 74 20 63 es useful, but c
0360: 6f 75 6c 64 20 62 65 20 72 65 61 6c 6c 79 20 61 ould be really a
0370: 6e 6e 6f 79 69 6e 67 20 76 65 72 79 20 6f 66 74 nnoying very oft
0380: 65 6e 2e 3c 62 72 3e 0d 0a 3c 76 65 72 62 61 74 en.<br>..<verbat
0390: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 27 31 27 2c im>..SELECT '1',
03a0: 20 54 79 70 65 4f 66 28 20 27 31 27 20 29 2c 20 TypeOf( '1' ),
03b0: 43 41 53 54 20 28 20 27 31 27 20 41 53 20 49 4e CAST ( '1' AS IN
03c0: 54 45 47 45 52 20 29 2c 20 54 79 70 65 4f 66 28 TEGER ), TypeOf(
03d0: 20 43 41 53 54 20 28 20 27 31 27 20 41 53 20 49 CAST ( '1' AS I
03e0: 4e 54 45 47 45 52 20 29 20 29 3b 0d 0a 3c 2f 76 NTEGER ) );..</v
03f0: 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 erbatim>..<table
0400: 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c 6c border="1" cell
0410: 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c spacing="4" cell
0420: 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 padding="4">..<t
0430: 72 3e 3c 74 68 3e 27 31 27 3c 2f 74 68 3e 3c 74 r><th>'1'</th><t
0440: 68 3e 54 79 70 65 4f 66 28 20 27 31 27 20 29 3c h>TypeOf( '1' )<
0450: 2f 74 68 3e 3c 74 68 3e 43 41 53 54 20 28 20 27 /th><th>CAST ( '
0460: 31 27 20 41 53 20 49 4e 54 45 47 45 52 20 29 3c 1' AS INTEGER )<
0470: 2f 74 68 3e 3c 74 68 3e 54 79 70 65 4f 66 28 20 /th><th>TypeOf(
0480: 43 41 53 54 20 28 20 27 31 27 20 41 53 20 49 4e CAST ( '1' AS IN
0490: 54 45 47 45 52 20 29 20 29 3c 2f 74 68 3e 3c 2f TEGER ) )</th></
04a0: 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 31 3c 2f tr>..<tr><td>1</
04b0: 74 64 3e 3c 74 64 3e 74 65 78 74 3c 2f 74 64 3e td><td>text</td>
04c0: 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 <td align="right
04d0: 22 3e 31 3c 2f 74 64 3e 3c 74 64 3e 69 6e 74 65 ">1</td><td>inte
04e0: 67 65 72 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 ger</td></tr></t
04f0: 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 53 able><br>..The S
0500: 51 4c 20 3c 62 3e 43 41 53 54 3c 2f 62 3e 20 6f QL <b>CAST</b> o
0510: 70 65 72 61 74 6f 72 20 61 6c 72 65 61 64 79 20 perator already
0520: 73 75 70 70 6f 72 74 73 20 74 68 65 20 70 6f 73 supports the pos
0530: 73 69 62 69 6c 69 74 79 20 74 6f 20 65 78 70 6c sibility to expl
0540: 69 63 69 74 6c 79 20 73 65 74 20 61 20 64 61 74 icitly set a dat
0550: 61 2d 74 79 70 65 3b 20 6e 6f 77 20 73 74 61 72 a-type; now star
0560: 74 69 6e 67 20 73 69 6e 63 65 20 34 2e 31 2e 30 ting since 4.1.0
0570: 20 53 70 61 74 69 61 4c 69 74 65 20 73 75 70 70 SpatiaLite supp
0580: 6f 72 74 73 20 66 65 77 20 53 51 4c 20 66 75 6e orts few SQL fun
0590: 63 74 69 6f 6e 73 20 70 65 72 66 6f 72 6d 69 6e ctions performin
05a0: 67 20 74 68 65 20 73 61 6d 65 20 74 61 73 6b 2e g the same task.
05b0: 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 <br>..<u>Please
05c0: 6e 6f 74 65 3c 2f 75 3e 3a 20 73 6f 6d 65 20 73 note</u>: some s
05d0: 75 62 74 6c 65 20 64 69 66 66 65 72 65 6e 63 65 ubtle difference
05e0: 73 20 65 78 69 73 74 73 20 68 65 72 65 20 61 6e s exists here an
05f0: 64 20 74 68 65 72 65 3b 20 70 6c 65 61 73 65 20 d there; please
0600: 63 61 72 65 66 75 6c 6c 79 20 72 65 61 64 20 74 carefully read t
0610: 68 69 73 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f his documentatio
0620: 6e 20 70 61 67 65 2e 0d 0a 3c 76 65 72 62 61 74 n page...<verbat
0630: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 61 73 74 im>..SELECT Cast
0640: 54 6f 49 6e 74 65 67 65 72 28 20 31 20 29 2c 20 ToInteger( 1 ),
0650: 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20 31 CastToInteger( 1
0660: 2e 34 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 65 .4 ), CastToInte
0670: 67 65 72 28 20 31 2e 36 20 29 2c 20 0d 0a 20 20 ger( 1.6 ), ..
0680: 20 20 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 CastToInteger(
0690: 20 27 31 32 33 27 20 29 2c 20 43 61 73 74 54 6f '123' ), CastTo
06a0: 49 6e 74 65 67 65 72 28 20 27 61 6c 70 68 61 27 Integer( 'alpha'
06b0: 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 65 67 65 ), CastToIntege
06c0: 72 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 r ( zeroblob(4)
06d0: 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d );..</verbatim>.
06e0: 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d 22 .<table border="
06f0: 31 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 1" cellspacing="
0700: 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 4" cellpadding="
0710: 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 4">..<tr><th>Cas
0720: 74 54 6f 49 6e 74 65 67 65 72 28 20 31 20 29 3c tToInteger( 1 )<
0730: 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e /th><th>CastToIn
0740: 74 65 67 65 72 28 20 31 2e 34 20 29 3c 2f 74 68 teger( 1.4 )</th
0750: 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 ><th>CastToInteg
0760: 65 72 28 20 31 2e 36 20 29 3c 2f 74 68 3e 3c 74 er( 1.6 )</th><t
0770: 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 h>CastToInteger(
0780: 20 27 31 32 33 27 20 29 3c 2f 74 68 3e 3c 74 68 '123' )</th><th
0790: 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20 >CastToInteger(
07a0: 27 61 6c 70 68 61 27 20 29 3c 2f 74 68 3e 3c 74 'alpha' )</th><t
07b0: 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 20 h>CastToInteger
07c0: 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3c ( zeroblob(4) )<
07d0: 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c /th></tr>..<tr><
07e0: 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 td align="right"
07f0: 3e 31 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e >1</td><td align
0800: 3d 22 72 69 67 68 74 22 3e 31 3c 2f 74 64 3e 3c ="right">1</td><
0810: 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 td align="right"
0820: 3e 32 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e >2</td><td align
0830: 3d 22 72 69 67 68 74 22 3e 31 32 33 3c 2f 74 64 ="right">123</td
0840: 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 ><td>NULL</td><t
0850: 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 2f 74 72 3e d>NULL</td></tr>
0860: 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 </table><br>..Th
0870: 65 20 3c 62 3e 43 61 73 74 54 6f 49 6e 74 65 67 e <b>CastToInteg
0880: 65 72 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e er()</b> SQL fun
0890: 63 74 69 6f 6e 20 77 69 6c 6c 20 61 74 74 65 6d ction will attem
08a0: 70 74 20 74 6f 20 72 65 74 75 72 6e 20 61 20 76 pt to return a v
08b0: 61 6c 75 65 20 6f 66 20 74 68 65 20 3c 62 3e 49 alue of the <b>I
08c0: 6e 74 65 67 65 72 3c 2f 62 3e 20 64 61 74 61 2d nteger</b> data-
08d0: 74 79 70 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c type, or <b>NULL
08e0: 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 6f 6e 76 65 </b> if no conve
08f0: 72 73 69 6f 6e 20 69 73 20 70 6f 73 73 69 62 6c rsion is possibl
0900: 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e e...<ul>..<li>an
0910: 20 49 6e 74 65 67 65 72 20 69 6e 70 75 74 20 61 Integer input a
0920: 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 62 65 20 rgument will be
0930: 72 65 74 75 72 6e 65 64 20 61 62 73 6f 6c 75 74 returned absolut
0940: 65 6c 79 20 75 6e 61 66 66 65 63 74 65 64 2e 3c ely unaffected.<
0950: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75 62 /li>..<li>a Doub
0960: 6c 65 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e le input argumen
0970: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 t will return th
0980: 65 20 3c 75 3e 6e 65 61 72 65 73 74 3c 2f 75 3e e <u>nearest</u>
0990: 20 49 6e 74 65 67 65 72 20 76 61 6c 75 65 20 28 Integer value (
09a0: 61 66 74 65 72 20 61 70 70 6c 79 69 6e 67 20 3c after applying <
09b0: 62 3e 34 2f 35 3c 2f 62 3e 20 72 6f 75 6e 64 69 b>4/5</b> roundi
09c0: 6e 67 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 ng).</li>..<li>a
09d0: 20 54 65 78 74 20 69 6e 70 75 74 20 61 72 67 75 Text input argu
09e0: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e ment will return
09f0: 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 the correspondi
0a00: 6e 67 20 49 6e 74 65 67 65 72 20 76 61 6c 75 65 ng Integer value
0a10: 20 6f 6e 6c 79 20 69 66 20 74 68 65 20 74 65 78 only if the tex
0a20: 74 20 73 74 72 69 6e 67 20 72 65 70 72 65 73 65 t string represe
0a30: 6e 74 73 20 61 20 76 61 6c 69 64 20 6e 75 6d 62 nts a valid numb
0a40: 65 72 20 28 65 76 65 6e 20 61 20 64 65 63 69 6d er (even a decim
0a50: 61 6c 20 6f 6e 65 29 3a 20 69 66 20 74 68 65 20 al one): if the
0a60: 74 65 78 74 20 73 74 72 69 6e 67 20 63 61 6e 6e text string cann
0a70: 6f 74 20 62 65 20 63 6f 6e 76 65 72 74 65 64 20 ot be converted
0a80: 74 6f 20 61 20 6e 75 6d 62 65 72 20 4e 55 4c 4c to a number NULL
0a90: 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 will be returne
0aa0: 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 d.</li>..<li>any
0ab0: 20 42 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 75 BLOB input argu
0ac0: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e ment will return
0ad0: 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f a NULL value.</
0ae0: 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c li>..<li>any NUL
0af0: 4c 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 L input argument
0b00: 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e will return a N
0b10: 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d ULL value.</li>.
0b20: 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 68 72 3e .</ul><br>..<hr>
0b30: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 ..<verbatim>..SE
0b40: 4c 45 43 54 20 43 61 73 74 54 6f 44 6f 75 62 6c LECT CastToDoubl
0b50: 65 28 20 31 20 29 2c 20 43 61 73 74 54 6f 44 6f e( 1 ), CastToDo
0b60: 75 62 6c 65 28 20 31 2e 32 33 20 29 2c 20 43 61 uble( 1.23 ), Ca
0b70: 73 74 54 6f 44 6f 75 62 6c 65 28 20 27 31 32 33 stToDouble( '123
0b80: 2e 34 35 27 20 29 2c 0d 0a 20 20 20 20 43 61 73 .45' ),.. Cas
0b90: 74 54 6f 44 6f 75 62 6c 65 28 20 27 61 6c 70 68 tToDouble( 'alph
0ba0: 61 27 20 29 2c 20 43 61 73 74 54 6f 44 6f 75 62 a' ), CastToDoub
0bb0: 6c 65 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 le ( zeroblob(4)
0bc0: 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e );..</verbatim>
0bd0: 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d ..<table border=
0be0: 22 31 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d "1" cellspacing=
0bf0: 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d "4" cellpadding=
0c00: 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 "4">..<tr><th>Ca
0c10: 73 74 54 6f 44 6f 75 62 6c 65 28 20 31 20 29 3c stToDouble( 1 )<
0c20: 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f /th><th>CastToDo
0c30: 75 62 6c 65 28 20 31 2e 32 33 20 29 3c 2f 74 68 uble( 1.23 )</th
0c40: 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 6c ><th>CastToDoubl
0c50: 65 28 20 27 31 32 33 2e 34 35 27 20 29 3c 2f 74 e( '123.45' )</t
0c60: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 h><th>CastToDoub
0c70: 6c 65 28 20 27 61 6c 70 68 61 27 20 29 3c 2f 74 le( 'alpha' )</t
0c80: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 h><th>CastToDoub
0c90: 6c 65 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 le ( zeroblob(4)
0ca0: 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 )</th></tr>..<t
0cb0: 72 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 r><td align="rig
0cc0: 68 74 22 3e 31 2e 30 30 30 30 30 30 3c 2f 74 64 ht">1.000000</td
0cd0: 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 ><td align="righ
0ce0: 74 22 3e 31 2e 32 33 30 30 30 30 3c 2f 74 64 3e t">1.230000</td>
0cf0: 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 <td align="right
0d00: 22 3e 31 32 33 2e 34 35 30 30 30 3c 2f 74 64 3e ">123.45000</td>
0d10: 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 <td>NULL</td><td
0d20: 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 2f 74 72 3e 3c >NULL</td></tr><
0d30: 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 /table><br>..The
0d40: 20 3c 62 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 <b>CastToDouble
0d50: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 ()</b> SQL funct
0d60: 69 6f 6e 20 77 69 6c 6c 20 61 74 74 65 6d 70 74 ion will attempt
0d70: 20 74 6f 20 72 65 74 75 72 6e 20 61 20 76 61 6c to return a val
0d80: 75 65 20 6f 66 20 74 68 65 20 3c 62 3e 44 6f 75 ue of the <b>Dou
0d90: 62 6c 65 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70 ble</b> data-typ
0da0: 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 e, or <b>NULL</b
0db0: 3e 20 69 66 20 6e 6f 20 63 6f 6e 76 65 72 73 69 > if no conversi
0dc0: 6f 6e 20 69 73 20 70 6f 73 73 69 62 6c 65 2e 0d on is possible..
0dd0: 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 6e .<ul>..<li>an In
0de0: 74 65 67 65 72 20 69 6e 70 75 74 20 61 72 67 75 teger input argu
0df0: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e ment will return
0e00: 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 the correspondi
0e10: 6e 67 20 44 6f 75 62 6c 65 20 76 61 6c 75 65 2e ng Double value.
0e20: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75 </li>..<li>a Dou
0e30: 62 6c 65 20 69 6e 70 75 74 20 61 72 67 75 6d 65 ble input argume
0e40: 6e 74 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 nt will be retur
0e50: 6e 65 64 20 61 62 73 6f 6c 75 74 65 6c 79 20 75 ned absolutely u
0e60: 6e 61 66 66 65 63 74 65 64 2e 3c 2f 6c 69 3e 0d naffected.</li>.
0e70: 0a 3c 6c 69 3e 61 20 54 65 78 74 20 69 6e 70 75 .<li>a Text inpu
0e80: 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 t argument will
0e90: 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 72 65 return the corre
0ea0: 73 70 6f 6e 64 69 6e 67 20 44 6f 75 62 6c 65 20 sponding Double
0eb0: 76 61 6c 75 65 20 6f 6e 6c 79 20 69 66 20 74 68 value only if th
0ec0: 65 20 74 65 78 74 20 73 74 72 69 6e 67 20 72 65 e text string re
0ed0: 70 72 65 73 65 6e 74 73 20 61 20 76 61 6c 69 64 presents a valid
0ee0: 20 6e 75 6d 62 65 72 3a 20 69 66 20 74 68 65 20 number: if the
0ef0: 74 65 78 74 20 73 74 72 69 6e 67 20 63 61 6e 6e text string cann
0f00: 6f 74 20 62 65 20 63 6f 6e 76 65 72 74 65 64 20 ot be converted
0f10: 74 6f 20 61 20 6e 75 6d 62 65 72 20 4e 55 4c 4c to a number NULL
0f20: 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 will be returne
0f30: 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 d.</li>..<li>any
0f40: 20 42 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 75 BLOB input argu
0f50: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e ment will return
0f60: 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f a NULL value.</
0f70: 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c li>..<li>any NUL
0f80: 4c 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 L input argument
0f90: 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e will return a N
0fa0: 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d ULL value.</li>.
0fb0: 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 68 72 3e .</ul><br>..<hr>
0fc0: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 ..<verbatim>..SE
0fd0: 4c 45 43 54 20 43 61 73 74 54 6f 54 65 78 74 28 LECT CastToText(
0fe0: 20 31 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 1 ), CastToText
0ff0: 28 20 31 2e 35 20 29 2c 20 43 61 73 74 54 6f 54 ( 1.5 ), CastToT
1000: 65 78 74 28 20 27 61 6c 70 68 61 27 20 29 2c 20 ext( 'alpha' ),
1010: 43 61 73 74 54 6f 54 65 78 74 20 28 20 7a 65 72 CastToText ( zer
1020: 6f 62 6c 6f 62 28 34 29 20 29 3b 0d 0a 3c 2f 76 oblob(4) );..</v
1030: 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 erbatim>..<table
1040: 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c 6c border="1" cell
1050: 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c spacing="4" cell
1060: 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 padding="4">..<t
1070: 72 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 r><th>CastToText
1080: 28 20 31 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 ( 1 )</th><th>Ca
1090: 73 74 54 6f 54 65 78 74 28 20 31 2e 35 20 29 3c stToText( 1.5 )<
10a0: 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 /th><th>CastToTe
10b0: 78 74 28 20 27 61 6c 70 68 61 27 20 29 3c 2f 74 xt( 'alpha' )</t
10c0: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 h><th>CastToText
10d0: 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 ( zeroblob(4) )
10e0: 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e </th></tr>..<tr>
10f0: 3c 74 64 3e 31 3c 2f 74 64 3e 3c 74 64 3e 31 2e <td>1</td><td>1.
1100: 35 3c 2f 74 64 3e 3c 74 64 3e 61 6c 70 68 61 3c 5</td><td>alpha<
1110: 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 /td><td>NULL</td
1120: 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 ></tr></table><b
1130: 72 3e 0d 0a 54 68 65 20 3c 62 3e 43 61 73 74 54 r>..The <b>CastT
1140: 6f 54 65 78 74 28 29 3c 2f 62 3e 20 53 51 4c 20 oText()</b> SQL
1150: 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 61 74 function will at
1160: 74 65 6d 70 74 20 74 6f 20 72 65 74 75 72 6e 20 tempt to return
1170: 61 20 76 61 6c 75 65 20 6f 66 20 74 68 65 20 3c a value of the <
1180: 62 3e 54 65 78 74 3c 2f 62 3e 20 64 61 74 61 2d b>Text</b> data-
1190: 74 79 70 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c type, or <b>NULL
11a0: 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 6f 6e 76 65 </b> if no conve
11b0: 72 73 69 6f 6e 20 69 73 20 70 6f 73 73 69 62 6c rsion is possibl
11c0: 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e e...<ul>..<li>an
11d0: 20 49 6e 74 65 67 65 72 20 69 6e 70 75 74 20 61 Integer input a
11e0: 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 rgument will ret
11f0: 75 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f urn the correspo
1200: 6e 64 69 6e 67 20 54 65 78 74 20 76 61 6c 75 65 nding Text value
1210: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f .</li>..<li>a Do
1220: 75 62 6c 65 20 69 6e 70 75 74 20 61 72 67 75 6d uble input argum
1230: 65 6e 74 20 77 69 6c 6c 20 62 65 20 72 65 74 75 ent will be retu
1240: 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e rn the correspon
1250: 64 69 6e 67 20 54 65 78 74 20 76 61 6c 75 65 3b ding Text value;
1260: 20 6e 6f 20 73 69 67 6e 69 66 69 63 61 6e 74 20 no significant
1270: 64 65 63 69 6d 61 6c 20 64 69 67 69 74 20 77 69 decimal digit wi
1280: 6c 6c 20 62 65 20 73 75 70 70 72 65 73 73 65 64 ll be suppressed
1290: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 54 65 .</li>..<li>a Te
12a0: 78 74 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e xt input argumen
12b0: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 t will return th
12c0: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 e corresponding
12d0: 44 6f 75 62 6c 65 20 76 61 6c 75 65 2e 3c 2f 6c Double value.</l
12e0: 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 42 4c 4f 42 i>..<li>any BLOB
12f0: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 input argument
1300: 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55 will return a NU
1310: 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a LL value.</li>..
1320: 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c 20 69 6e 70 <li>any NULL inp
1330: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c ut argument will
1340: 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 return a NULL v
1350: 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c alue.</li>..</ul
1360: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 >..<verbatim>..S
1370: 45 4c 45 43 54 20 43 61 73 74 54 6f 54 65 78 74 ELECT CastToText
1380: 28 20 31 2c 20 34 20 29 2c 20 43 61 73 74 54 6f ( 1, 4 ), CastTo
1390: 54 65 78 74 28 20 31 32 33 34 2c 20 32 20 29 2c Text( 1234, 2 ),
13a0: 20 43 61 73 74 54 6f 54 65 78 74 28 20 31 2c 20 CastToText( 1,
13b0: 38 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 28 8 ), CastToText(
13c0: 20 31 2e 35 2c 20 34 20 29 3b 0d 0a 3c 2f 76 65 1.5, 4 );..</ve
13d0: 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 rbatim>..<table
13e0: 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c 6c 73 border="1" cells
13f0: 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 pacing="4" cellp
1400: 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 adding="4">..<tr
1410: 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 28 ><th>CastToText(
1420: 20 31 2c 20 34 20 29 3c 2f 74 68 3e 3c 74 68 3e 1, 4 )</th><th>
1430: 43 61 73 74 54 6f 54 65 78 74 28 20 31 32 33 34 CastToText( 1234
1440: 2c 20 32 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 , 2 )</th><th>Ca
1450: 73 74 54 6f 54 65 78 74 28 20 31 2c 20 38 20 29 stToText( 1, 8 )
1460: 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54 </th><th>CastToT
1470: 65 78 74 28 20 31 2e 35 2c 20 34 20 29 3c 2f 74 ext( 1.5, 4 )</t
1480: 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 h></tr>..<tr><td
1490: 3e 30 30 30 31 3c 2f 74 64 3e 3c 74 64 3e 31 32 >0001</td><td>12
14a0: 33 34 3c 2f 74 64 3e 3c 74 64 3e 30 30 30 30 30 34</td><td>00000
14b0: 30 30 31 3c 2f 74 64 3e 3c 74 64 3e 30 30 30 31 001</td><td>0001
14c0: 2e 35 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 .5</td></tr></ta
14d0: 62 6c 65 3e 3c 62 72 3e 0d 0a 41 6e 20 6f 76 65 ble><br>..An ove
14e0: 72 6c 6f 61 64 65 64 20 76 65 72 73 69 6f 6e 20 rloaded version
14f0: 6f 66 20 3c 62 3e 43 61 73 74 54 6f 54 65 78 74 of <b>CastToText
1500: 28 29 3c 2f 62 3e 20 69 73 20 73 75 70 70 6f 72 ()</b> is suppor
1510: 74 65 64 20 61 73 20 77 65 6c 6c 2c 20 62 75 74 ted as well, but
1520: 20 6f 6e 6c 79 20 77 68 65 6e 20 74 68 65 20 69 only when the i
1530: 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 69 73 nput argument is
1540: 20 6f 66 20 74 68 65 20 49 6e 74 65 67 65 72 20 of the Integer
1550: 6f 72 20 44 6f 75 62 6c 65 20 64 61 74 61 2d 74 or Double data-t
1560: 79 70 65 3a 20 69 6e 20 74 68 69 73 20 63 61 73 ype: in this cas
1570: 65 20 61 20 73 65 63 6f 6e 64 20 49 6e 74 65 67 e a second Integ
1580: 65 72 20 61 72 67 75 6d 65 6e 74 20 63 6f 75 6c er argument coul
1590: 64 20 62 65 20 6f 70 74 69 6f 6e 61 6c 6c 79 20 d be optionally
15a0: 73 70 65 63 69 66 69 65 64 2c 20 61 6e 64 20 77 specified, and w
15b0: 69 6c 6c 20 62 65 20 69 6e 74 65 72 70 72 65 74 ill be interpret
15c0: 65 64 20 61 64 20 3c 62 3e 7a 65 72 6f 2d 70 61 ed ad <b>zero-pa
15d0: 64 64 69 6e 67 2d 6c 65 6e 67 74 68 3c 2f 62 3e dding-length</b>
15e0: 2e 3c 62 72 3e 0d 0a 69 2e 65 2e 20 74 68 65 20 .<br>..i.e. the
15f0: 72 65 74 75 72 6e 65 64 20 54 65 78 74 20 73 74 returned Text st
1600: 72 69 6e 67 20 69 6e 20 74 68 69 73 20 63 61 73 ring in this cas
1610: 65 20 77 69 6c 6c 20 68 61 76 65 20 61 6e 20 69 e will have an i
1620: 6e 74 65 67 65 72 20 70 61 72 74 20 61 74 20 6c nteger part at l
1630: 65 61 73 74 20 6f 66 20 74 68 65 20 73 70 65 63 east of the spec
1640: 69 66 69 65 64 20 6c 65 6e 67 74 68 2c 20 61 6e ified length, an
1650: 64 20 65 76 65 6e 74 75 61 6c 6c 79 20 70 61 64 d eventually pad
1660: 64 65 64 20 62 79 20 69 6e 73 65 72 74 69 6e 67 ded by inserting
1670: 20 6e 6f 74 20 73 69 67 6e 69 66 69 63 61 6e 74 not significant
1680: 20 6c 65 61 64 69 6e 67 20 5a 45 52 4f 65 73 2e leading ZEROes.
1690: 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a <br><br>..<hr>..
16a0: 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 <verbatim>..SELE
16b0: 43 54 20 43 61 73 74 54 6f 42 6c 6f 62 28 20 31 CT CastToBlob( 1
16c0: 20 29 2c 20 43 61 73 74 54 6f 42 6c 6f 62 28 20 ), CastToBlob(
16d0: 31 2e 35 20 29 2c 20 48 65 78 28 20 43 61 73 74 1.5 ), Hex( Cast
16e0: 54 6f 42 6c 6f 62 28 20 27 61 6c 70 68 61 27 20 ToBlob( 'alpha'
16f0: 29 20 29 2c 20 48 65 78 20 28 20 43 61 73 74 54 ) ), Hex ( CastT
1700: 6f 42 6c 6f 62 20 28 20 7a 65 72 6f 62 6c 6f 62 oBlob ( zeroblob
1710: 28 34 29 20 29 20 29 3b 0d 0a 3c 2f 76 65 72 62 (4) ) );..</verb
1720: 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f atim>..<table bo
1730: 72 64 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 rder="1" cellspa
1740: 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 cing="4" cellpad
1750: 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c ding="4">..<tr><
1760: 74 68 3e 43 61 73 74 54 6f 42 6c 6f 62 28 20 31 th>CastToBlob( 1
1770: 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 )</th><th>CastT
1780: 6f 42 6c 6f 62 28 20 31 2e 35 20 29 3c 2f 74 68 oBlob( 1.5 )</th
1790: 3e 3c 74 68 3e 48 65 78 28 20 43 61 73 74 54 6f ><th>Hex( CastTo
17a0: 42 6c 6f 62 28 20 27 61 6c 70 68 61 27 20 29 20 Blob( 'alpha' )
17b0: 29 3c 2f 74 68 3e 3c 74 68 3e 48 65 78 28 20 43 )</th><th>Hex( C
17c0: 61 73 74 54 6f 54 65 78 74 20 28 20 7a 65 72 6f astToText ( zero
17d0: 62 6c 6f 62 28 34 29 20 29 20 29 3c 2f 74 68 3e blob(4) ) )</th>
17e0: 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 4e </tr>..<tr><td>N
17f0: 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c ULL</td><td>NULL
1800: 3c 2f 74 64 3e 3c 74 64 3e 36 31 36 43 37 30 36 </td><td>616C706
1810: 38 36 31 3c 2f 74 64 3e 3c 74 64 3e 30 30 30 30 861</td><td>0000
1820: 30 30 30 30 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 0000</td></tr></
1830: 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 table><br>..The
1840: 3c 62 3e 43 61 73 74 54 6f 42 6c 6f 62 28 29 3c <b>CastToBlob()<
1850: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e /b> SQL function
1860: 20 77 69 6c 6c 20 61 74 74 65 6d 70 74 20 74 6f will attempt to
1870: 20 72 65 74 75 72 6e 20 61 20 76 61 6c 75 65 20 return a value
1880: 6f 66 20 74 68 65 20 3c 62 3e 42 4c 4f 42 3c 2f of the <b>BLOB</
1890: 62 3e 20 64 61 74 61 2d 74 79 70 65 2c 20 6f 72 b> data-type, or
18a0: 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e 20 69 66 20 <b>NULL</b> if
18b0: 6e 6f 20 63 6f 6e 76 65 72 73 69 6f 6e 20 69 73 no conversion is
18c0: 20 70 6f 73 73 69 62 6c 65 2e 0d 0a 3c 75 6c 3e possible...<ul>
18d0: 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74 65 67 65 72 ..<li>an Integer
18e0: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 input argument
18f0: 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55 will return a NU
1900: 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a LL value.</li>..
1910: 3c 6c 69 3e 61 20 44 6f 75 62 6c 65 20 69 6e 70 <li>a Double inp
1920: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c ut argument will
1930: 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 return a NULL v
1940: 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e alue.</li>..<li>
1950: 61 20 54 65 78 74 20 69 6e 70 75 74 20 61 72 67 a Text input arg
1960: 75 6d 65 6e 74 20 20 77 69 6c 6c 20 72 65 74 75 ument will retu
1970: 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e rn the correspon
1980: 64 69 6e 67 20 42 4c 4f 42 20 76 61 6c 75 65 2e ding BLOB value.
1990: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 42 </li>..<li>any B
19a0: 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 75 6d 65 LOB input argume
19b0: 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 nt will return t
19c0: 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 he corresponding
19d0: 20 42 4c 4f 42 20 76 61 6c 75 65 2e 3c 2f 6c 69 BLOB value.</li
19e0: 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c 20 >..<li>any NULL
19f0: 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 input argument w
1a00: 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55 4c ill return a NUL
1a10: 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c L value.</li>..<
1a20: 2f 75 6c 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e /ul>..<verbatim>
1a30: 0d 0a 53 45 4c 45 43 54 20 48 65 78 28 20 43 61 ..SELECT Hex( Ca
1a40: 73 74 54 6f 42 6c 6f 62 28 20 27 30 31 32 33 34 stToBlob( '01234
1a50: 35 36 37 38 39 61 42 63 44 65 46 66 45 64 43 62 56789aBcDeFfEdCb
1a60: 41 39 38 37 36 35 34 33 32 31 30 27 2c 20 31 20 A9876543210', 1
1a70: 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 30 31 32 ) );..-----..012
1a80: 33 34 35 36 37 38 39 41 42 43 44 45 46 46 45 44 3456789ABCDEFFED
1a90: 43 42 41 39 38 37 36 35 34 33 32 31 30 0d 0a 0d CBA9876543210...
1aa0: 0a 53 45 4c 45 43 54 20 43 61 73 74 54 6f 42 6c .SELECT CastToBl
1ab0: 6f 62 28 20 27 31 32 66 27 2c 20 31 20 29 3b 0d ob( '12f', 1 );.
1ac0: 0a 2d 2d 2d 2d 2d 0d 0a 4e 55 4c 4c 0d 0a 0d 0a .-----..NULL....
1ad0: 53 45 4c 45 43 54 20 43 61 73 74 54 6f 42 6c 6f SELECT CastToBlo
1ae0: 62 28 20 27 31 32 48 46 27 2c 20 31 20 29 3b 0d b( '12HF', 1 );.
1af0: 0a 2d 2d 2d 2d 2d 0d 0a 4e 55 4c 4c 0d 0a 3c 2f .-----..NULL..</
1b00: 76 65 72 62 61 74 69 6d 3e 0d 0a 41 20 73 65 63 verbatim>..A sec
1b10: 6f 6e 64 20 6f 76 65 72 6c 6f 61 64 65 64 20 76 ond overloaded v
1b20: 65 72 73 69 6f 6e 20 6f 66 20 3c 62 3e 43 61 73 ersion of <b>Cas
1b30: 74 54 6f 42 6c 6f 62 28 29 3c 2f 62 3e 20 69 73 tToBlob()</b> is
1b40: 20 73 75 70 70 6f 72 74 65 64 20 61 73 20 77 65 supported as we
1b50: 6c 6c 3b 20 62 79 20 73 70 65 63 69 66 79 69 6e ll; by specifyin
1b60: 67 20 61 20 66 75 72 74 68 65 72 20 3c 62 3e 68 g a further <b>h
1b70: 65 78 5f 69 6e 70 75 74 3c 2f 62 3e 20 3c 75 3e ex_input</b> <u>
1b80: 62 6f 6f 6c 65 61 6e 3c 2f 75 3e 20 61 72 67 75 boolean</u> argu
1b90: 6d 65 6e 74 20 73 65 74 20 61 73 20 3c 62 3e 54 ment set as <b>T
1ba0: 52 55 45 3c 2f 62 3e 20 74 68 65 20 69 6e 70 75 RUE</b> the inpu
1bb0: 74 20 73 74 72 69 6e 67 20 77 69 6c 6c 20 62 65 t string will be
1bc0: 20 61 73 73 75 6d 65 64 20 74 6f 20 62 65 20 3c assumed to be <
1bd0: 75 3e 48 65 78 61 64 65 63 69 6d 61 6c 6c 79 20 u>Hexadecimally
1be0: 65 6e 63 6f 64 65 64 3c 2f 75 3e 2e 20 49 6e 20 encoded</u>. In
1bf0: 74 68 69 73 20 63 61 73 65 20 4e 55 4c 4c 20 77 this case NULL w
1c00: 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 20 ill be returned
1c10: 69 66 20 74 68 65 20 69 6e 70 75 74 20 73 74 72 if the input str
1c20: 69 6e 67 20 64 6f 65 73 6e 27 74 20 63 6f 72 72 ing doesn't corr
1c30: 65 73 70 6f 6e 64 73 20 74 6f 20 61 20 76 61 6c esponds to a val
1c40: 69 64 20 48 65 78 61 64 65 63 69 6d 61 6c 20 6e id Hexadecimal n
1c50: 6f 74 61 74 69 6f 6e 2e 3c 62 72 3e 3c 62 72 3e otation.<br><br>
1c60: 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 ..<hr>..<verbati
1c70: 6d 3e 0d 0a 53 45 4c 45 43 54 20 46 6f 72 63 65 m>..SELECT Force
1c80: 41 73 4e 75 6c 6c 28 20 27 61 27 2c 20 27 62 27 AsNull( 'a', 'b'
1c90: 20 29 2c 20 46 6f 72 63 65 41 73 4e 75 6c 6c 28 ), ForceAsNull(
1ca0: 20 27 61 62 63 64 27 2c 20 27 61 62 63 64 27 20 'abcd', 'abcd'
1cb0: 29 2c 20 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 ), ForceAsNull(
1cc0: 31 2c 20 31 29 2c 20 46 6f 72 63 65 41 73 4e 75 1, 1), ForceAsNu
1cd0: 6c 6c 28 20 31 2e 31 2c 20 31 20 29 3b 0d 0a 3c ll( 1.1, 1 );..<
1ce0: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 /verbatim>..<tab
1cf0: 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 le border="1" ce
1d00: 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 llspacing="4" ce
1d10: 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a llpadding="4">..
1d20: 3c 74 72 3e 3c 74 68 3e 46 6f 72 63 65 41 73 4e <tr><th>ForceAsN
1d30: 75 6c 6c 28 20 27 61 27 2c 20 27 62 27 20 29 3c ull( 'a', 'b' )<
1d40: 2f 74 68 3e 3c 74 68 3e 46 6f 72 63 65 41 73 4e /th><th>ForceAsN
1d50: 75 6c 6c 28 20 27 61 62 63 64 27 2c 20 27 61 62 ull( 'abcd', 'ab
1d60: 63 64 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 46 6f cd' )</th><th>Fo
1d70: 72 63 65 41 73 4e 75 6c 6c 28 20 31 2c 20 31 29 rceAsNull( 1, 1)
1d80: 3c 2f 74 68 3e 3c 74 68 3e 46 6f 72 63 65 41 73 </th><th>ForceAs
1d90: 4e 75 6c 6c 28 20 31 2e 31 2c 20 2d 39 39 39 39 Null( 1.1, -9999
1da0: 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 )</th></tr>..<t
1db0: 72 3e 3c 74 64 3e 61 3c 2f 74 64 3e 3c 74 64 3e r><td>a</td><td>
1dc0: 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c NULL</td><td>NUL
1dd0: 4c 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d L</td><td align=
1de0: 22 72 69 67 68 74 22 3e 31 2e 31 3c 2f 74 64 3e "right">1.1</td>
1df0: 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 </tr></table><br
1e00: 3e 0d 0a 54 68 65 20 3c 62 3e 46 6f 72 63 65 41 >..The <b>ForceA
1e10: 73 4e 75 6c 6c 28 29 3c 2f 62 3e 20 53 51 4c 20 sNull()</b> SQL
1e20: 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 65 76 function will ev
1e30: 61 6c 75 61 74 65 20 74 77 6f 20 61 72 62 69 74 aluate two arbit
1e40: 72 61 72 79 20 61 72 67 75 6d 65 6e 74 73 2e 3c rary arguments.<
1e50: 62 72 3e 0d 0a 49 66 20 74 68 65 79 20 61 72 65 br>..If they are
1e60: 20 65 71 75 61 6c 20 61 6e 64 20 65 78 61 63 74 equal and exact
1e70: 6c 79 20 6f 66 20 74 68 65 20 73 61 6d 65 20 64 ly of the same d
1e80: 61 74 61 2d 74 79 70 65 20 4e 55 4c 4c 20 77 69 ata-type NULL wi
1e90: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 3b 20 ll be returned;
1ea0: 6f 74 68 65 72 77 69 73 65 20 74 68 65 20 66 69 otherwise the fi
1eb0: 72 73 74 20 61 72 67 75 6d 65 6e 74 20 76 61 6c rst argument val
1ec0: 75 65 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 ue will be retur
1ed0: 6e 65 64 2e 3c 62 72 3e 0d 0a 55 73 65 66 75 6c ned.<br>..Useful
1ee0: 20 65 2e 67 2e 20 77 68 69 6c 65 20 70 72 6f 63 e.g. while proc
1ef0: 65 73 73 69 6e 67 20 64 61 74 61 20 69 6d 70 6f essing data impo
1f00: 72 74 65 64 20 66 72 6f 6d 20 61 6e 79 20 3c 62 rted from any <b
1f10: 3e 53 68 61 70 65 66 69 6c 65 3c 2f 62 3e 20 6f >Shapefile</b> o
1f20: 72 20 3c 62 3e 44 42 46 20 66 69 6c 65 3c 2f 62 r <b>DBF file</b
1f30: 3e 20 28 73 75 63 68 20 66 6f 72 6d 61 74 73 20 > (such formats
1f40: 64 6f 65 73 6e 27 74 20 73 75 70 70 6f 72 74 20 doesn't support
1f50: 61 6e 79 20 72 65 61 6c 20 4e 55 4c 4c 20 76 61 any real NULL va
1f60: 6c 75 65 2c 20 6f 66 74 65 6e 20 62 65 69 6e 67 lue, often being
1f70: 20 72 65 70 6c 61 63 65 64 20 62 79 20 73 6f 6d replaced by som
1f80: 65 20 63 6f 6e 76 65 6e 74 69 6f 6e 61 6c 20 76 e conventional v
1f90: 61 6c 75 65 20 65 2e 67 2e 20 3c 62 3e 30 3c 2f alue e.g. <b>0</
1fa0: 62 3e 20 6f 72 20 3c 62 3e 2d 39 39 39 39 3c 2f b> or <b>-9999</
1fb0: 62 3e 20 61 6e 64 20 61 6c 69 6b 65 29 2e 3c 62 b> and alike).<b
1fc0: 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68 r><br>..<hr>..<h
1fd0: 33 3e 3c 61 20 6e 61 6d 65 3d 22 75 75 69 64 22 3><a name="uuid"
1fe0: 3e 47 65 6e 65 72 69 63 3c 2f 61 3e 20 53 51 4c >Generic</a> SQL
1ff0: 20 66 75 6e 63 74 69 6f 6e 73 20 2d 20 55 55 49 functions - UUI
2000: 44 20 67 65 6e 65 72 61 74 6f 72 3c 2f 68 33 3e D generator</h3>
2010: 0d 0a 41 6e 20 3c 61 20 68 72 65 66 3d 22 68 74 ..An <a href="ht
2020: 74 70 3a 2f 2f 65 6e 2e 77 69 6b 69 70 65 64 69 tp://en.wikipedi
2030: 61 2e 6f 72 67 2f 77 69 6b 69 2f 55 6e 69 76 65 a.org/wiki/Unive
2040: 72 73 61 6c 6c 79 5f 75 6e 69 71 75 65 5f 69 64 rsally_unique_id
2050: 65 6e 74 69 66 69 65 72 22 3e 55 6e 69 76 65 72 entifier">Univer
2060: 73 61 6c 6c 79 20 75 6e 69 71 75 65 20 69 64 65 sally unique ide
2070: 6e 74 69 66 69 65 72 3c 2f 61 3e 20 28 61 6b 61 ntifier</a> (aka
2080: 20 3c 62 3e 55 55 49 44 3c 2f 62 3e 29 20 73 69 <b>UUID</b>) si
2090: 6d 70 6c 79 20 69 73 20 61 20 3c 75 3e 31 32 38 mply is a <u>128
20a0: 20 62 69 74 3c 2f 75 3e 20 49 6e 74 65 67 65 72 bit</u> Integer
20b0: 3b 20 61 63 63 6f 72 64 69 6e 67 6c 79 20 74 6f ; accordingly to
20c0: 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f <a href="http:/
20d0: 2f 65 6e 2e 77 69 6b 69 70 65 64 69 61 2e 6f 72 /en.wikipedia.or
20e0: 67 2f 77 69 6b 69 2f 55 55 49 44 23 52 61 6e 64 g/wiki/UUID#Rand
20f0: 6f 6d 5f 55 55 49 44 5f 70 72 6f 62 61 62 69 6c om_UUID_probabil
2100: 69 74 79 5f 6f 66 5f 64 75 70 6c 69 63 61 74 65 ity_of_duplicate
2110: 73 22 3e 74 68 65 6f 72 79 3c 2f 61 3e 2c 20 74 s">theory</a>, t
2120: 68 65 20 70 72 6f 62 61 62 69 6c 69 74 79 20 74 he probability t
2130: 68 61 74 20 74 77 6f 20 72 61 6e 64 6f 6d 6c 79 hat two randomly
2140: 20 67 65 6e 65 72 61 74 65 64 20 55 55 49 44 73 generated UUIDs
2150: 20 63 6f 75 6c 64 20 61 73 73 75 6d 65 20 74 68 could assume th
2160: 65 20 73 61 6d 65 20 76 61 6c 75 65 20 69 73 20 e same value is
2170: 6e 65 61 72 20 74 6f 20 7a 65 72 6f 20 66 6f 72 near to zero for
2180: 20 6d 61 6e 79 20 70 72 61 63 74 69 63 61 6c 20 many practical
2190: 70 75 72 70 6f 73 65 73 2e 20 41 6e 64 20 63 6f purposes. And co
21a0: 6e 73 65 71 75 65 6e 74 6c 79 20 55 55 49 44 73 nsequently UUIDs
21b0: 20 61 72 65 20 77 69 64 65 6c 79 20 75 73 65 64 are widely used
21c0: 20 61 73 20 3c 75 3e 75 6e 69 76 65 72 73 61 6c as <u>universal
21d0: 6c 79 20 75 6e 69 71 75 65 20 49 44 73 3c 2f 75 ly unique IDs</u
21e0: 3e 2e 3c 62 72 3e 0d 0a 55 73 75 61 6c 6c 79 20 >.<br>..Usually
21f0: 55 55 49 44 73 20 61 72 65 20 72 65 70 72 65 73 UUIDs are repres
2200: 65 6e 74 65 64 20 69 6e 20 74 68 65 69 72 20 3c ented in their <
2210: 75 3e 63 61 6e 6f 6e 69 63 61 6c 20 66 6f 72 6d u>canonical form
2220: 3c 2f 75 3e 2c 20 69 2e 65 2e 20 61 73 20 61 20 </u>, i.e. as a
2230: 73 65 71 75 65 6e 63 65 20 6f 66 20 33 32 20 68 sequence of 32 h
2240: 65 78 61 64 65 63 69 6d 61 6c 20 64 69 67 69 74 exadecimal digit
2250: 73 20 73 65 70 61 72 61 74 65 64 20 69 6e 74 6f s separated into
2260: 20 66 69 76 65 20 64 69 73 74 69 6e 63 74 20 62 five distinct b
2270: 6c 6f 63 6b 2c 20 61 63 63 6f 72 64 69 6e 67 6c lock, accordingl
2280: 79 20 74 6f 20 61 20 3c 62 3e 38 2d 34 2d 34 2d y to a <b>8-4-4-
2290: 34 2d 31 32 3c 2f 62 3e 20 73 63 68 65 6d 61 2e 4-12</b> schema.
22a0: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 ..<verbatim>..SE
22b0: 4c 45 43 54 20 43 72 65 61 74 65 55 55 49 44 28 LECT CreateUUID(
22c0: 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 66 66 );..--------..ff
22d0: 66 35 66 61 66 31 2d 64 63 63 30 2d 34 33 39 31 f5faf1-dcc0-4391
22e0: 2d 38 30 35 34 2d 36 65 37 64 65 37 35 64 38 35 -8054-6e7de75d85
22f0: 62 31 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d b1..</verbatim>.
2300: 0a 54 68 65 20 3c 62 3e 43 72 65 61 74 65 55 55 .The <b>CreateUU
2310: 49 44 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e ID()</b> SQL fun
2320: 63 74 69 6f 6e 20 69 73 20 62 75 69 6c 74 20 6f ction is built o
2330: 6e 20 74 68 65 20 74 6f 70 20 74 68 65 20 3c 69 n the top the <i
2340: 3e 48 69 67 68 20 51 75 61 6c 69 74 79 20 50 73 >High Quality Ps
2350: 65 75 64 6f 2d 52 61 6e 64 6f 6d 20 4e 75 6d 62 eudo-Random Numb
2360: 65 72 20 47 65 6e 65 72 61 74 6f 72 3c 2f 69 3e er Generator</i>
2370: 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f <a href="http:/
2380: 2f 77 77 77 2e 73 71 6c 69 74 65 2e 6f 72 67 2f /www.sqlite.org/
2390: 63 33 72 65 66 2f 72 61 6e 64 6f 6d 6e 65 73 73 c3ref/randomness
23a0: 2e 68 74 6d 6c 22 3e 69 6e 74 65 72 6e 61 6c 6c .html">internall
23b0: 79 20 69 6d 70 6c 65 6d 65 6e 74 65 64 3c 2f 61 y implemented</a
23c0: 3e 20 62 79 20 53 51 4c 69 74 65 2e 3c 62 72 3e > by SQLite.<br>
23d0: 0d 0a 54 68 65 20 72 65 74 75 72 6e 65 64 20 55 ..The returned U
23e0: 55 49 44 20 69 73 20 63 6f 6e 66 6f 72 6d 61 6e UID is conforman
23f0: 74 20 74 6f 20 3c 75 3e 56 65 72 73 69 6f 6e 20 t to <u>Version
2400: 34 20 28 72 61 6e 64 6f 6d 29 3c 2f 75 3e 20 28 4 (random)</u> (
2410: 69 2e 65 2e 20 74 68 65 20 66 69 72 73 74 20 64 i.e. the first d
2420: 69 67 69 74 20 69 6e 74 6f 20 74 68 65 20 74 68 igit into the th
2430: 69 72 64 20 62 6c 6f 63 6b 20 77 69 6c 6c 20 61 ird block will a
2440: 6c 77 61 79 73 20 62 65 20 3c 62 3e 34 3c 2f 62 lways be <b>4</b
2450: 3e 20 61 6e 64 20 74 68 65 20 66 69 72 73 74 20 > and the first
2460: 64 69 67 69 74 20 69 6e 74 6f 20 74 68 65 20 66 digit into the f
2470: 6f 75 72 74 68 20 62 6c 6f 63 6b 20 77 69 6c 6c ourth block will
2480: 20 61 6c 77 61 79 73 20 62 65 20 3c 62 3e 38 3c always be <b>8<
2490: 2f 62 3e 29 2e 3c 62 72 3e 0d 0a 3c 68 34 3e 4d /b>).<br>..<h4>M
24a0: 44 35 20 63 68 65 63 6b 73 75 6d 3c 2f 68 34 3e D5 checksum</h4>
24b0: 0d 0a 54 68 65 20 3c 61 20 68 72 65 66 3d 22 68 ..The <a href="h
24c0: 74 74 70 3a 2f 2f 65 6e 2e 77 69 6b 69 70 65 64 ttp://en.wikiped
24d0: 69 61 2e 6f 72 67 2f 77 69 6b 69 2f 4d 44 35 22 ia.org/wiki/MD5"
24e0: 3e 4d 44 35 20 61 6c 67 6f 72 69 74 68 6d 3c 2f >MD5 algorithm</
24f0: 61 3e 20 69 73 20 77 65 6c 6c 20 6b 6e 6f 77 6e a> is well known
2500: 20 61 6e 64 20 77 69 64 65 6c 79 20 75 73 65 64 and widely used
2510: 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 63 6f 6d in order to com
2520: 70 75 74 65 20 3c 75 3e 3c 69 3e 68 61 73 68 20 pute <u><i>hash
2530: 2f 20 63 68 65 63 6b 73 75 6d 3c 2f 69 3e 3c 2f / checksum</i></
2540: 75 3e 20 64 69 67 65 73 74 73 2c 20 61 6e 64 20 u> digests, and
2550: 69 74 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 it corresponds t
2560: 6f 20 20 61 20 66 6f 72 6d 61 6c 6c 79 20 64 65 o a formally de
2570: 66 69 6e 65 64 20 73 70 65 63 69 66 69 63 61 74 fined specificat
2580: 69 6f 6e 20 64 20 28 3c 61 20 68 72 65 66 3d 22 ion d (<a href="
2590: 68 74 74 70 3a 2f 2f 74 6f 6f 6c 73 2e 69 65 74 http://tools.iet
25a0: 66 2e 6f 72 67 2f 68 74 6d 6c 2f 72 66 63 31 33 f.org/html/rfc13
25b0: 32 31 22 3e 52 46 43 31 33 32 31 3c 2f 61 3e 29 21">RFC1321</a>)
25c0: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 41 6e 79 20 3c .<br><br>..Any <
25d0: 62 3e 4d 44 35 20 63 68 65 63 6b 73 75 6d 3c 2f b>MD5 checksum</
25e0: 62 3e 20 61 6c 77 61 79 73 20 63 6f 72 72 65 73 b> always corres
25f0: 70 6f 6e 64 73 20 74 6f 20 61 20 31 32 38 2d 62 ponds to a 128-b
2600: 69 74 20 6e 75 6d 62 65 72 2c 20 61 6e 64 20 69 it number, and i
2610: 73 20 75 73 75 61 6c 6c 79 20 70 72 69 6e 74 65 s usually printe
2620: 64 20 69 6e 20 69 74 73 20 3c 75 3e 3c 69 3e 68 d in its <u><i>h
2630: 65 78 61 64 65 63 69 6d 61 6c 3c 2f 69 3e 3c 2f exadecimal</i></
2640: 75 3e 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f u> representatio
2650: 6e 2e 3c 62 72 3e 0d 0a 41 63 63 6f 72 64 69 6e n.<br>..Accordin
2660: 67 6c 79 20 74 6f 20 74 68 65 6f 72 79 2c 20 69 gly to theory, i
2670: 74 27 73 20 76 65 72 79 20 69 6d 70 72 6f 62 61 t's very improba
2680: 62 6c 65 20 74 68 61 74 20 74 77 6f 20 64 69 66 ble that two dif
2690: 66 65 72 65 6e 74 20 3c 69 3e 6d 65 73 73 61 67 ferent <i>messag
26a0: 65 73 3c 2f 69 3e 20 63 6f 75 6c 64 20 63 6f 6c es</i> could col
26b0: 6c 69 64 65 20 67 65 6e 65 72 61 74 69 6e 67 20 lide generating
26c0: 74 68 65 20 73 61 6d 65 20 69 64 65 6e 74 69 63 the same identic
26d0: 61 6c 20 63 68 65 63 6b 73 75 6d 3b 20 61 6e 64 al checksum; and
26e0: 20 65 76 65 6e 20 73 6c 69 67 68 74 6c 79 20 64 even slightly d
26f0: 69 66 66 65 72 65 6e 74 20 3c 69 3e 6d 65 73 73 ifferent <i>mess
2700: 61 67 65 73 3c 2f 69 3e 20 28 6a 75 73 74 20 64 ages</i> (just d
2710: 69 66 66 65 72 69 6e 67 20 66 6f 72 20 66 65 77 iffering for few
2720: 20 62 69 74 73 29 20 61 72 65 20 65 78 70 65 63 bits) are expec
2730: 74 65 64 20 74 6f 20 70 72 6f 64 75 63 65 20 73 ted to produce s
2740: 74 72 69 6b 69 6e 67 6c 79 20 64 69 66 66 65 72 trikingly differ
2750: 65 6e 74 20 63 68 65 63 6b 73 75 6d 73 2e 3c 62 ent checksums.<b
2760: 72 3e 0d 0a 53 6f 20 74 68 65 20 3c 62 3e 4d 44 r>..So the <b>MD
2770: 35 20 63 68 65 63 6b 73 75 6d 3c 2f 62 3e 20 63 5 checksum</b> c
2780: 61 6e 20 62 65 20 73 61 66 65 6c 79 20 61 73 73 an be safely ass
2790: 75 6d 65 64 20 74 6f 20 72 65 70 72 65 73 65 6e umed to represen
27a0: 74 20 61 20 3c 75 3e 3c 69 3e 64 69 67 69 74 61 t a <u><i>digita
27b0: 6c 20 73 69 67 6e 61 74 75 72 65 3c 2f 69 3e 3c l signature</i><
27c0: 2f 75 3e 20 75 6e 69 71 75 65 6c 79 20 69 64 65 /u> uniquely ide
27d0: 6e 74 69 66 79 69 6e 67 20 61 6e 79 20 67 65 6e ntifying any gen
27e0: 65 72 69 63 20 62 69 6e 61 72 79 20 6f 62 6a 65 eric binary obje
27f0: 63 74 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d ct...<verbatim>.
2800: 0a 53 45 4c 45 43 54 20 4d 44 35 43 68 65 63 6b .SELECT MD5Check
2810: 73 75 6d 28 47 65 6f 6d 46 72 6f 6d 54 65 78 74 sum(GeomFromText
2820: 28 27 4c 49 4e 45 53 54 52 49 4e 47 28 31 31 20 ('LINESTRING(11
2830: 34 31 2c 20 31 32 20 34 32 29 27 2c 20 34 33 32 41, 12 42)', 432
2840: 36 29 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 0d 0a 37 30 6));..------..70
2850: 31 66 32 63 32 33 31 61 35 66 62 34 38 39 62 65 1f2c231a5fb489be
2860: 31 63 37 38 34 65 32 34 31 65 61 39 35 38 0d 0a 1c784e241ea958..
2870: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 </verbatim>..The
2880: 20 3c 62 3e 4d 44 35 43 68 65 63 6b 73 75 6d 28 <b>MD5Checksum(
2890: 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 )</b> SQL functi
28a0: 6f 6e 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 on will return t
28b0: 68 65 20 63 68 65 63 6b 73 75 6d 20 63 6f 72 72 he checksum corr
28c0: 65 73 70 6f 6e 64 69 6e 67 20 74 6f 20 61 6e 79 esponding to any
28d0: 20 67 65 6e 65 72 69 63 20 42 4c 4f 42 20 28 74 generic BLOB (t
28e0: 68 69 73 20 6f 62 76 69 6f 75 73 6c 79 20 69 6e his obviously in
28f0: 63 6c 75 64 69 6e 67 20 47 65 6f 6d 65 74 72 69 cluding Geometri
2900: 65 73 29 20 6f 72 20 54 45 58 54 20 73 74 72 69 es) or TEXT stri
2910: 6e 67 2e 3c 62 72 3e 0d 0a 54 68 65 20 75 6e 64 ng.<br>..The und
2920: 65 72 6c 79 69 6e 67 20 69 6d 70 6c 65 6d 65 6e erlying implemen
2930: 74 61 74 69 6f 6e 20 69 73 20 64 69 72 65 63 74 tation is direct
2940: 6c 79 20 62 61 73 65 64 20 6f 6e 20 74 68 65 20 ly based on the
2950: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f <a href="http://
2960: 6f 70 65 6e 77 61 6c 6c 2e 69 6e 66 6f 2f 77 69 openwall.info/wi
2970: 6b 69 2f 70 65 6f 70 6c 65 2f 73 6f 6c 61 72 2f ki/people/solar/
2980: 73 6f 66 74 77 61 72 65 2f 70 75 62 6c 69 63 2d software/public-
2990: 64 6f 6d 61 69 6e 2d 73 6f 75 72 63 65 2d 63 6f domain-source-co
29a0: 64 65 2f 6d 64 35 22 3e 63 6f 64 65 3c 2f 61 3e de/md5">code</a>
29b0: 20 64 65 76 65 6c 6f 70 65 64 20 62 79 20 41 6c developed by Al
29c0: 65 78 61 6e 64 65 72 20 50 65 73 6c 79 61 6b 20 exander Peslyak
29d0: 61 6e 64 20 72 65 6c 65 61 73 65 64 20 6f 6e 20 and released on
29e0: 74 68 65 20 50 75 62 6c 69 63 20 44 6f 6d 61 69 the Public Domai
29f0: 6e 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a n...<verbatim>..
2a00: 53 45 4c 45 43 54 20 4d 44 35 54 6f 74 61 6c 43 SELECT MD5TotalC
2a10: 68 65 63 6b 73 75 6d 28 67 65 6f 6d 65 74 72 79 hecksum(geometry
2a20: 29 0d 0a 46 52 4f 4d 20 63 6f 6d 32 30 31 31 3b )..FROM com2011;
2a30: 0d 0a 2d 2d 2d 2d 2d 2d 0d 0a 38 65 62 30 30 32 ..------..8eb002
2a40: 36 35 38 39 39 30 30 32 32 61 36 66 30 63 31 63 658990022a6f0c1c
2a50: 62 32 34 61 36 30 66 62 66 36 0d 0a 3c 2f 76 65 b24a60fbf6..</ve
2a60: 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e rbatim>..The <b>
2a70: 4d 44 35 54 6f 74 61 6c 43 68 65 63 6b 73 75 6d MD5TotalChecksum
2a80: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 ()</b> SQL funct
2a90: 69 6f 6e 20 77 69 6c 6c 20 70 65 72 66 6f 72 6d ion will perform
2aa0: 20 65 78 61 63 74 6c 79 20 74 68 65 20 73 61 6d exactly the sam
2ab0: 65 20 69 64 65 6e 74 69 63 61 6c 20 74 61 73 6b e identical task
2ac0: 20 62 75 74 20 69 73 20 69 6d 70 6c 65 6d 65 6e but is implemen
2ad0: 74 65 64 20 61 73 20 61 6e 20 3c 75 3e 3c 69 3e ted as an <u><i>
2ae0: 61 67 67 72 65 67 61 74 65 20 66 75 6e 63 74 69 aggregate functi
2af0: 6f 6e 3c 2f 69 3e 3c 2f 75 3e 2e 0d 0a 3c 62 72 on</i></u>...<br
2b00: 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68 33 ><br>..<hr>..<h3
2b10: 3e 3c 61 20 6e 61 6d 65 3d 22 67 65 6f 6d 22 3e ><a name="geom">
2b20: 53 70 61 74 69 61 6c 3c 2f 61 3e 20 53 51 4c 20 Spatial</a> SQL
2b30: 66 75 6e 63 74 69 6f 6e 73 3c 2f 68 33 3e 0d 0a functions</h3>..
2b40: 46 65 77 20 6d 6f 72 65 20 53 70 61 74 69 61 6c Few more Spatial
2b50: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 61 SQL functions a
2b60: 72 65 20 6e 6f 77 20 73 75 70 70 6f 72 74 65 64 re now supported
2b70: 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 ...<verbatim>..S
2b80: 45 4c 45 43 54 20 53 54 5f 41 73 54 65 78 74 28 ELECT ST_AsText(
2b90: 20 53 54 5f 41 64 64 50 6f 69 6e 74 28 20 0d 0a ST_AddPoint( ..
2ba0: 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 ST_GeomFromTex
2bb0: 74 28 20 27 4c 49 4e 45 53 54 52 49 4e 47 28 20 t( 'LINESTRING(
2bc0: 30 20 30 2c 20 31 20 30 20 29 27 20 29 2c 20 0d 0 0, 1 0 )' ), .
2bd0: 0a 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 . ST_GeomFromTe
2be0: 78 74 28 20 27 50 4f 49 4e 54 28 20 31 20 31 20 xt( 'POINT( 1 1
2bf0: 29 27 20 29 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d )' ) ) );..-----
2c00: 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e 47 28 ---..LINESTRING(
2c10: 30 20 30 2c 20 31 20 30 2c 20 31 20 31 29 0d 0a 0 0, 1 0, 1 1)..
2c20: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 </verbatim>..The
2c30: 20 3c 62 3e 53 54 5f 41 64 64 50 6f 69 6e 74 28 <b>ST_AddPoint(
2c40: 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 )</b> SQL functi
2c50: 6f 6e 20 61 64 64 73 20 61 20 66 75 72 74 68 65 on adds a furthe
2c60: 72 20 50 6f 69 6e 74 2f 56 65 72 74 65 78 20 61 r Point/Vertex a
2c70: 74 20 74 68 65 20 65 6e 64 20 6f 66 20 61 20 4c t the end of a L
2c80: 69 6e 65 73 74 72 69 6e 67 3b 20 74 68 65 20 66 inestring; the f
2c90: 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 69 73 irst argument is
2ca0: 20 61 6c 77 61 79 73 20 65 78 70 65 63 74 65 64 always expected
2cb0: 20 74 6f 20 62 65 20 6f 66 20 74 68 65 20 4c 69 to be of the Li
2cc0: 6e 65 73 74 72 69 6e 67 20 74 79 70 65 2c 20 74 nestring type, t
2cd0: 68 65 20 73 65 63 6f 6e 64 20 6f 6e 65 20 6d 75 he second one mu
2ce0: 73 74 20 62 65 20 61 20 50 6f 69 6e 74 2e 0d 0a st be a Point...
2cf0: 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 <verbatim>..SELE
2d00: 43 54 20 53 54 5f 41 73 54 65 78 74 28 20 53 54 CT ST_AsText( ST
2d10: 5f 41 64 64 50 6f 69 6e 74 28 20 0d 0a 20 20 53 _AddPoint( .. S
2d20: 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 T_GeomFromText(
2d30: 27 4c 49 4e 45 53 54 52 49 4e 47 28 20 31 20 30 'LINESTRING( 1 0
2d40: 2c 20 31 20 31 20 29 27 20 29 2c 20 0d 0a 20 20 , 1 1 )' ), ..
2d50: 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 ST_GeomFromText(
2d60: 20 27 50 4f 49 4e 54 28 20 30 20 30 20 29 27 20 'POINT( 0 0 )'
2d70: 29 2c 20 30 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d ), 0 ) );..-----
2d80: 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e 47 ----..LINESTRING
2d90: 28 30 20 30 2c 20 31 20 30 2c 20 31 20 31 29 0d (0 0, 1 0, 1 1).
2da0: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 49 66 .</verbatim>..If
2db0: 20 61 6e 20 6f 70 74 69 6f 6e 61 6c 20 74 68 69 an optional thi
2dc0: 72 64 20 61 72 67 75 6d 65 6e 74 20 28 6f 66 20 rd argument (of
2dd0: 74 68 65 20 49 6e 74 65 67 65 72 20 74 79 70 65 the Integer type
2de0: 29 20 69 73 20 70 61 73 73 65 64 20 74 6f 20 3c ) is passed to <
2df0: 62 3e 53 54 5f 41 64 64 50 6f 69 6e 74 28 29 3c b>ST_AddPoint()<
2e00: 2f 62 3e 20 69 74 27 73 20 69 6e 74 65 6e 64 65 /b> it's intende
2e10: 64 20 74 6f 20 73 70 65 63 69 66 79 20 74 68 65 d to specify the
2e20: 20 3c 75 3e 69 6e 64 65 78 3c 2f 75 3e 20 6f 66 <u>index</u> of
2e30: 20 74 68 65 20 6e 65 77 20 56 65 72 74 65 78 20 the new Vertex
2e40: 28 66 69 72 73 74 20 56 65 72 74 65 78 20 68 61 (first Vertex ha
2e50: 73 20 69 6e 64 65 78 20 30 2c 20 73 65 63 6f 6e s index 0, secon
2e60: 64 20 56 65 72 74 65 78 20 68 61 73 20 69 6e 64 d Vertex has ind
2e70: 65 78 20 31 20 61 6e 64 20 73 6f 20 6f 6e 29 2e ex 1 and so on).
2e80: 3c 62 72 3e 0d 0a 52 65 66 65 72 65 6e 63 69 6e <br>..Referencin
2e90: 67 20 61 20 6e 6f 74 20 65 78 69 73 74 69 6e 67 g a not existing
2ea0: 20 69 6e 64 65 78 20 69 73 20 61 6e 20 65 72 72 index is an err
2eb0: 6f 72 2c 20 61 6e 64 20 77 69 6c 6c 20 72 65 74 or, and will ret
2ec0: 75 72 6e 20 4e 55 4c 4c 2e 0d 0a 3c 76 65 72 62 urn NULL...<verb
2ed0: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54 atim>..SELECT ST
2ee0: 5f 41 73 54 65 78 74 28 20 53 54 5f 41 64 64 50 _AsText( ST_AddP
2ef0: 6f 69 6e 74 28 20 0d 0a 20 20 53 54 5f 47 65 6f oint( .. ST_Geo
2f00: 6d 46 72 6f 6d 54 65 78 74 28 20 27 4c 49 4e 45 mFromText( 'LINE
2f10: 53 54 52 49 4e 47 28 20 30 20 30 2c 20 31 20 30 STRING( 0 0, 1 0
2f20: 20 29 27 20 29 2c 20 0d 0a 20 20 53 54 5f 47 65 )' ), .. ST_Ge
2f30: 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 50 4f 49 omFromText( 'POI
2f40: 4e 54 28 20 31 20 31 20 29 27 20 29 2c 20 2d 31 NT( 1 1 )' ), -1
2f50: 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d ) );..--------.
2f60: 0a 4c 49 4e 45 53 54 52 49 4e 47 28 30 20 30 2c .LINESTRING(0 0,
2f70: 20 31 20 30 2c 20 31 20 31 29 0d 0a 3c 2f 76 65 1 0, 1 1)..</ve
2f80: 72 62 61 74 69 6d 3e 0d 0a 50 61 73 73 69 6e 67 rbatim>..Passing
2f90: 20 61 20 6e 65 67 61 74 69 76 65 20 69 6e 64 65 a negative inde
2fa0: 78 20 69 73 20 61 20 73 75 70 70 6f 72 74 65 64 x is a supported
2fb0: 20 6f 70 74 69 6f 6e 2c 20 61 6e 64 20 73 69 6d option, and sim
2fc0: 70 6c 79 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 ply corresponds
2fd0: 74 6f 20 74 68 65 20 64 65 66 61 75 6c 74 20 62 to the default b
2fe0: 65 68 61 76 69 6f 75 72 20 28 69 2e 65 2e 20 3c ehaviour (i.e. <
2ff0: 69 3e 61 70 70 65 6e 64 69 6e 67 20 74 68 65 20 i>appending the
3000: 50 6f 69 6e 74 20 74 6f 20 74 68 65 20 65 6e 64 Point to the end
3010: 20 6f 66 20 74 68 65 20 4c 69 6e 65 73 74 72 69 of the Linestri
3020: 6e 67 3c 2f 69 3e 29 2e 3c 62 72 3e 3c 62 72 3e ng</i>).<br><br>
3030: 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 ..<hr>..<verbati
3040: 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 73 m>..SELECT ST_As
3050: 54 65 78 74 28 20 53 54 5f 53 65 74 50 6f 69 6e Text( ST_SetPoin
3060: 74 28 20 0d 0a 20 20 53 54 5f 47 65 6f 6d 46 72 t( .. ST_GeomFr
3070: 6f 6d 54 65 78 74 28 20 27 4c 49 4e 45 53 54 52 omText( 'LINESTR
3080: 49 4e 47 28 20 30 20 30 2c 20 31 20 30 2c 20 31 ING( 0 0, 1 0, 1
3090: 20 31 20 29 27 20 29 2c 20 0d 0a 20 20 31 2c 20 1 )' ), .. 1,
30a0: 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 ST_GeomFromText(
30b0: 20 27 50 4f 49 4e 54 28 20 32 20 31 20 29 27 20 'POINT( 2 1 )'
30c0: 29 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d ) ) );..--------
30d0: 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e 47 28 30 20 -..LINESTRING(0
30e0: 30 2c 20 32 20 31 2c 20 31 20 31 29 0d 0a 3c 2f 0, 2 1, 1 1)..</
30f0: 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c verbatim>..The <
3100: 62 3e 53 54 5f 53 65 74 50 6f 69 6e 74 28 29 3c b>ST_SetPoint()<
3110: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e /b> SQL function
3120: 20 63 61 6e 20 72 65 70 6c 61 63 65 20 61 20 50 can replace a P
3130: 6f 69 6e 74 2f 56 65 72 74 65 78 20 66 72 6f 6d oint/Vertex from
3140: 20 77 69 74 68 69 6e 20 61 20 4c 69 6e 65 73 74 within a Linest
3150: 72 69 6e 67 3b 20 74 68 65 20 66 69 72 73 74 20 ring; the first
3160: 61 72 67 75 6d 65 6e 74 20 69 73 20 61 6c 77 61 argument is alwa
3170: 79 73 20 65 78 70 65 63 74 65 64 20 74 6f 20 62 ys expected to b
3180: 65 20 6f 66 20 74 68 65 20 4c 69 6e 65 73 74 72 e of the Linestr
3190: 69 6e 67 20 74 79 70 65 2c 20 74 68 65 20 73 65 ing type, the se
31a0: 63 6f 6e 64 20 69 73 20 61 6e 20 49 6e 74 65 67 cond is an Integ
31b0: 65 72 20 73 70 65 63 69 66 79 69 6e 67 20 74 68 er specifying th
31c0: 65 20 3c 75 3e 69 6e 64 65 78 3c 2f 75 3e 20 6f e <u>index</u> o
31d0: 66 20 74 68 65 20 61 66 66 65 63 74 65 64 20 56 f the affected V
31e0: 65 72 74 65 78 20 61 6e 64 20 74 68 65 20 74 68 ertex and the th
31f0: 69 72 64 20 6f 6e 65 20 6d 75 73 74 20 62 65 20 ird one must be
3200: 61 20 50 6f 69 6e 74 2e 3c 62 72 3e 0d 0a 52 65 a Point.<br>..Re
3210: 66 65 72 65 6e 63 69 6e 67 20 61 20 6e 6f 74 20 ferencing a not
3220: 65 78 69 73 74 69 6e 67 20 69 6e 64 65 78 20 69 existing index i
3230: 73 20 61 6e 20 65 72 72 6f 72 2c 20 61 6e 64 20 s an error, and
3240: 77 69 6c 6c 20 72 65 74 75 72 6e 20 4e 55 4c 4c will return NULL
3250: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d .<br><br>..<hr>.
3260: 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c .<verbatim>..SEL
3270: 45 43 54 20 53 54 5f 41 73 54 65 78 74 28 20 53 ECT ST_AsText( S
3280: 54 5f 52 65 6d 6f 76 65 50 6f 69 6e 74 28 20 0d T_RemovePoint( .
3290: 0a 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 . ST_GeomFromTe
32a0: 78 74 28 20 27 4c 49 4e 45 53 54 52 49 4e 47 28 xt( 'LINESTRING(
32b0: 20 30 20 30 2c 20 31 20 30 2c 20 31 20 31 20 29 0 0, 1 0, 1 1 )
32c0: 27 20 29 2c 20 31 20 29 20 29 3b 0d 0a 2d 2d 2d ' ), 1 ) );..---
32d0: 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49 ------..LINESTRI
32e0: 4e 47 28 30 20 30 2c 20 31 20 31 29 0d 0a 3c 2f NG(0 0, 1 1)..</
32f0: 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c verbatim>..The <
3300: 62 3e 53 54 5f 52 65 6d 6f 76 65 50 6f 69 6e 74 b>ST_RemovePoint
3310: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 ()</b> SQL funct
3320: 69 6f 6e 20 63 61 6e 20 72 65 6d 6f 76 65 20 61 ion can remove a
3330: 20 50 6f 69 6e 74 2f 56 65 72 74 65 78 20 66 72 Point/Vertex fr
3340: 6f 6d 20 77 69 74 68 69 6e 20 61 20 4c 69 6e 65 om within a Line
3350: 73 74 72 69 6e 67 3b 20 74 68 65 20 66 69 72 73 string; the firs
3360: 74 20 61 72 67 75 6d 65 6e 74 20 69 73 20 61 6c t argument is al
3370: 77 61 79 73 20 65 78 70 65 63 74 65 64 20 74 6f ways expected to
3380: 20 62 65 20 6f 66 20 74 68 65 20 4c 69 6e 65 73 be of the Lines
3390: 74 72 69 6e 67 20 74 79 70 65 2c 20 74 68 65 20 tring type, the
33a0: 73 65 63 6f 6e 64 20 69 73 20 61 6e 20 49 6e 74 second is an Int
33b0: 65 67 65 72 20 73 70 65 63 69 66 79 69 6e 67 20 eger specifying
33c0: 74 68 65 20 3c 75 3e 69 6e 64 65 78 3c 2f 75 3e the <u>index</u>
33d0: 20 6f 66 20 74 68 65 20 61 66 66 65 63 74 65 64 of the affected
33e0: 20 56 65 72 74 65 78 2e 3c 62 72 3e 0d 0a 52 65 Vertex.<br>..Re
33f0: 66 65 72 65 6e 63 69 6e 67 20 61 20 6e 6f 74 20 ferencing a not
3400: 65 78 69 73 74 69 6e 67 20 69 6e 64 65 78 20 69 existing index i
3410: 73 20 61 6e 20 65 72 72 6f 72 2c 20 61 6e 64 20 s an error, and
3420: 77 69 6c 6c 20 72 65 74 75 72 6e 20 4e 55 4c 4c will return NULL
3430: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d .<br><br>..<hr>.
3440: 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c .<verbatim>..SEL
3450: 45 43 54 20 53 54 5f 41 73 54 65 78 74 28 20 53 ECT ST_AsText( S
3460: 54 5f 50 6f 69 6e 74 28 31 30 2c 20 32 30 29 20 T_Point(10, 20)
3470: 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a );..----------..
3480: 50 4f 49 4e 54 28 31 30 20 31 30 29 0d 0a 3c 2f POINT(10 10)..</
3490: 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c verbatim>..The <
34a0: 62 3e 53 54 5f 50 6f 69 6e 74 28 29 3c 2f 62 3e b>ST_Point()</b>
34b0: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 73 69 SQL function si
34c0: 6d 70 6c 79 20 69 73 20 79 65 74 20 61 6e 6f 74 mply is yet anot
34d0: 68 65 72 20 3c 69 3e 61 6c 69 61 73 2d 6e 61 6d her <i>alias-nam
34e0: 65 3c 2f 69 3e 20 63 6f 72 72 65 73 70 6f 6e 64 e</i> correspond
34f0: 69 6e 67 20 74 6f 20 3c 62 3e 4d 61 6b 65 50 6f ing to <b>MakePo
3500: 69 6e 74 28 29 3c 2f 62 3e 3b 20 74 68 69 73 20 int()</b>; this
3510: 66 75 72 74 68 65 72 20 61 6c 69 61 73 20 68 61 further alias ha
3520: 73 20 62 65 65 6e 20 69 6e 74 72 6f 64 75 63 65 s been introduce
3530: 64 20 73 6f 20 74 6f 20 73 75 70 70 6f 72 74 20 d so to support
3540: 61 20 73 74 72 69 63 74 20 50 6f 73 74 47 49 53 a strict PostGIS
3550: 20 63 6f 6e 66 6f 72 6d 61 6e 63 65 2e 3c 62 72 conformance.<br
3560: 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 >..<u>Please not
3570: 65 3c 2f 75 3e 3a 20 64 69 66 66 65 72 65 6e 74 e</u>: different
3580: 6c 79 20 66 72 6f 6d 20 4d 61 6b 65 50 6f 69 6e ly from MakePoin
3590: 74 28 29 2c 20 53 54 5f 50 6f 69 6e 74 28 29 20 t(), ST_Point()
35a0: 64 6f 6e 27 74 20 73 75 70 70 6f 72 74 73 20 74 don't supports t
35b0: 68 65 20 6f 70 74 69 6f 6e 61 6c 20 3c 62 3e 53 he optional <b>S
35c0: 52 49 44 3c 2f 62 3e 20 61 72 67 75 6d 65 6e 74 RID</b> argument
35d0: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d .<br><br>..<hr>.
35e0: 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c .<verbatim>..SEL
35f0: 45 43 54 20 53 54 5f 41 73 54 65 78 74 28 20 4d ECT ST_AsText( M
3600: 61 6b 65 4c 69 6e 65 28 20 53 54 5f 47 65 6f 6d akeLine( ST_Geom
3610: 46 72 6f 6d 54 65 78 74 28 20 27 4d 55 4c 54 49 FromText( 'MULTI
3620: 50 4f 49 4e 54 28 30 20 30 2c 20 31 20 30 2c 20 POINT(0 0, 1 0,
3630: 31 20 31 29 27 20 29 20 29 20 2c 20 31 20 29 3b 1 1)' ) ) , 1 );
3640: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 ..----------..LI
3650: 4e 45 53 54 52 49 4e 47 28 30 20 30 2c 20 31 20 NESTRING(0 0, 1
3660: 30 2c 20 31 20 31 29 0d 0a 0d 0a 53 45 4c 45 43 0, 1 1)....SELEC
3670: 54 20 53 54 5f 41 73 54 65 78 74 28 20 4d 61 6b T ST_AsText( Mak
3680: 65 4c 69 6e 65 28 20 53 54 5f 47 65 6f 6d 46 72 eLine( ST_GeomFr
3690: 6f 6d 54 65 78 74 28 20 27 4d 55 4c 54 49 50 4f omText( 'MULTIPO
36a0: 49 4e 54 28 30 20 30 2c 20 31 20 30 2c 20 31 20 INT(0 0, 1 0, 1
36b0: 31 29 27 20 29 20 29 20 2c 20 30 20 29 3b 0d 0a 1)' ) ) , 0 );..
36c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 ----------..LINE
36d0: 53 54 52 49 4e 47 28 31 20 31 2c 20 31 20 30 2c STRING(1 1, 1 0,
36e0: 20 30 20 30 29 0d 0a 3c 2f 76 65 72 62 61 74 69 0 0)..</verbati
36f0: 6d 3e 0d 0a 4e 6f 74 20 72 65 61 6c 6c 79 20 61 m>..Not really a
3700: 20 62 72 61 6e 64 20 6e 65 77 20 53 51 4c 20 66 brand new SQL f
3710: 75 6e 63 74 69 6f 6e 3b 20 6d 6f 72 65 20 73 69 unction; more si
3720: 6d 70 6c 79 20 61 20 66 75 72 74 68 65 72 20 6f mply a further o
3730: 76 65 72 6c 6f 61 64 65 64 20 66 6c 61 76 6f 72 verloaded flavor
3740: 20 6f 66 20 74 68 65 20 61 6c 72 65 61 64 79 20 of the already
3750: 65 78 69 73 74 69 6e 67 20 3c 62 3e 4d 61 6b 65 existing <b>Make
3760: 4c 69 6e 65 28 29 3c 2f 62 3e 2e 3c 62 72 3e 0d Line()</b>.<br>.
3770: 0a 4e 6f 77 20 74 68 65 20 69 6e 70 75 74 20 47 .Now the input G
3780: 65 6f 6d 65 74 72 79 20 28 66 69 72 73 74 20 61 eometry (first a
3790: 72 67 75 6d 65 6e 74 29 20 63 6f 75 6c 64 20 62 rgument) could b
37a0: 65 20 6f 66 20 74 68 65 20 4d 55 4c 54 49 50 4f e of the MULTIPO
37b0: 49 4e 54 20 74 79 70 65 20 61 6e 64 20 74 68 65 INT type and the
37c0: 20 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 second argument
37d0: 20 69 66 20 6f 66 20 74 68 65 20 3c 62 3e 42 6f if of the <b>Bo
37e0: 6f 6c 65 61 6e 3c 2f 62 3e 20 74 79 70 65 3b 20 olean</b> type;
37f0: 69 66 20 74 68 65 20 73 65 63 6f 6e 64 20 61 72 if the second ar
3800: 67 75 6d 65 6e 74 20 63 6f 72 72 65 73 70 6f 6e gument correspon
3810: 64 73 20 74 6f 20 3c 62 3e 54 52 55 45 3c 2f 62 ds to <b>TRUE</b
3820: 3e 20 74 68 65 20 72 65 74 75 72 6e 65 64 20 4c > the returned L
3830: 49 4e 45 53 54 52 49 4e 47 20 77 69 6c 6c 20 62 INESTRING will b
3840: 65 20 6f 72 69 65 6e 74 65 64 20 61 63 63 6f 72 e oriented accor
3850: 64 69 6e 67 6c 79 20 74 6f 20 74 68 65 20 50 6f dingly to the Po
3860: 69 6e 74 2d 73 65 71 75 65 6e 63 65 20 61 73 20 int-sequence as
3870: 73 70 65 63 69 66 69 65 64 20 62 79 20 74 68 65 specified by the
3880: 20 4d 75 6c 74 69 50 6f 69 6e 74 2c 20 6f 74 68 MultiPoint, oth
3890: 65 72 77 69 73 65 20 3c 75 3e 72 65 76 65 72 73 erwise <u>revers
38a0: 65 20 6f 72 64 65 72 3c 2f 75 3e 20 77 69 6c 6c e order</u> will
38b0: 20 62 65 20 61 73 73 75 6d 65 64 2c 20 74 68 75 be assumed, thu
38c0: 73 20 72 65 74 75 72 6e 69 6e 67 20 61 20 4c 69 s returning a Li
38d0: 6e 65 73 74 72 69 6e 67 20 6f 66 20 6f 70 70 6f nestring of oppo
38e0: 73 69 74 65 20 6f 72 69 65 6e 74 61 74 69 6f 6e site orientation
38f0: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d .<br><br>..<hr>.
3900: 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c .<verbatim>..SEL
3910: 45 43 54 20 53 54 5f 41 72 65 61 28 20 53 54 5f ECT ST_Area( ST_
3920: 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 50 GeomFromText( 'P
3930: 4f 4c 59 47 4f 4e 28 28 32 30 20 32 30 2c 20 32 OLYGON((20 20, 2
3940: 31 20 32 30 2c 20 32 31 20 32 31 2c 20 32 30 20 1 20, 21 21, 20
3950: 32 31 2c 20 32 30 20 32 30 29 29 27 2c 20 34 33 21, 20 20))', 43
3960: 32 36 20 29 2c 20 31 20 29 3b 0d 0a 2d 2d 2d 2d 26 ), 1 );..----
3970: 2d 2d 2d 2d 2d 2d 0d 0a 31 31 35 34 38 35 35 35 ------..11548555
3980: 39 32 36 2e 36 34 37 37 33 36 0d 0a 0d 0a 0d 0a 926.647736......
3990: 53 45 4c 45 43 54 20 53 54 5f 41 72 65 61 28 20 SELECT ST_Area(
39a0: 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 ST_GeomFromText(
39b0: 20 27 50 4f 4c 59 47 4f 4e 28 28 32 30 20 32 30 'POLYGON((20 20
39c0: 2c 20 32 31 20 32 30 2c 20 32 31 20 32 31 2c 20 , 21 20, 21 21,
39d0: 32 30 20 32 31 2c 20 32 30 20 32 30 29 29 27 2c 20 21, 20 20))',
39e0: 20 34 33 32 36 20 29 2c 20 30 20 29 3b 0d 0a 2d 4326 ), 0 );..-
39f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 31 31 35 38 31 ---------..11581
3a00: 33 37 37 36 32 33 2e 31 31 34 31 38 39 0d 0a 3c 377623.114189..<
3a10: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 4f 6e 63 65 /verbatim>..Once
3a20: 20 61 67 61 69 6e 2c 20 73 69 6d 70 6c 79 20 61 again, simply a
3a30: 20 66 75 72 74 68 65 72 20 65 78 74 65 6e 73 69 further extensi
3a40: 6f 6e 20 6f 66 20 74 68 65 20 61 6c 72 65 61 64 on of the alread
3a50: 79 20 65 78 69 73 74 69 6e 67 20 3c 62 3e 53 54 y existing <b>ST
3a60: 5f 41 72 65 61 28 29 3c 2f 62 3e 2e 3c 62 72 3e _Area()</b>.<br>
3a70: 0d 0a 4e 6f 77 20 69 66 20 74 68 65 20 69 6e 70 ..Now if the inp
3a80: 75 74 20 47 65 6f 6d 65 74 72 79 20 61 64 6f 70 ut Geometry adop
3a90: 74 73 20 3c 75 3e 67 65 6f 67 72 61 70 68 69 63 ts <u>geographic
3aa0: 20 63 6f 6f 72 64 69 6e 61 74 65 73 3c 2f 75 3e coordinates</u>
3ab0: 20 28 69 2e 65 2e 20 62 61 73 65 64 20 6f 6e 20 (i.e. based on
3ac0: 3c 75 3e 6c 6f 6e 67 69 74 75 64 65 3c 2f 75 3e <u>longitude</u>
3ad0: 20 61 6e 64 20 3c 75 3e 6c 61 74 69 74 75 64 65 and <u>latitude
3ae0: 3c 2f 75 3e 20 61 6e 67 6c 65 73 29 2c 20 61 20 </u> angles), a
3af0: 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 20 second argument
3b00: 6f 66 20 74 68 65 20 3c 62 3e 42 6f 6f 6c 65 61 of the <b>Boolea
3b10: 6e 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70 65 20 n</b> data-type
3b20: 63 6f 75 6c 64 20 62 65 20 6f 70 74 69 6f 6e 61 could be optiona
3b30: 6c 6c 79 20 73 70 65 63 69 66 69 65 64 2e 3c 62 lly specified.<b
3b40: 72 3e 0d 0a 49 6e 20 74 68 69 73 20 63 61 73 65 r>..In this case
3b50: 20 74 68 65 20 72 65 74 75 72 6e 65 64 20 41 72 the returned Ar
3b60: 65 61 20 77 69 6c 6c 20 62 65 20 6d 65 61 73 75 ea will be measu
3b70: 72 65 64 20 69 6e 20 3c 62 3e 6d 65 74 65 72 73 red in <b>meters
3b80: 3c 2f 62 3e 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 </b>...<ul>..<li
3b90: 3e 69 66 20 74 68 65 20 73 65 63 6f 6e 64 20 61 >if the second a
3ba0: 72 67 20 69 73 20 3c 62 3e 54 52 55 45 3c 2f 62 rg is <b>TRUE</b
3bb0: 3e 20 74 68 65 20 41 72 65 61 20 77 69 6c 6c 20 > the Area will
3bc0: 62 65 20 6d 65 61 73 75 72 65 64 20 3c 75 3e 6f be measured <u>o
3bd0: 6e 20 74 68 65 20 45 6c 6c 69 70 73 6f 69 64 3c n the Ellipsoid<
3be0: 2f 75 3e 20 28 6d 6f 72 65 20 61 63 63 75 72 61 /u> (more accura
3bf0: 74 65 2c 20 62 75 74 20 73 6c 6f 77 65 72 29 2e te, but slower).
3c00: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 69 66 20 74 68 </li>..<li>if th
3c10: 65 20 73 65 63 6f 6e 64 20 61 72 67 20 69 73 20 e second arg is
3c20: 3c 62 3e 46 41 4c 53 45 3c 2f 62 3e 20 74 68 65 <b>FALSE</b> the
3c30: 20 41 72 65 61 20 77 69 6c 6c 20 62 65 20 6d 65 Area will be me
3c40: 61 73 75 72 65 20 3c 75 3e 6f 6e 20 74 68 65 20 asure <u>on the
3c50: 53 70 68 65 72 65 3c 2f 75 3e 20 28 66 61 73 74 Sphere</u> (fast
3c60: 65 72 2c 20 62 75 74 20 6c 65 73 73 20 61 63 63 er, but less acc
3c70: 75 72 61 74 65 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c urate).</li>..<l
3c80: 69 3e 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 20 72 i>NULL will be r
3c90: 65 74 75 72 6e 65 64 20 6f 6e 20 69 6e 76 61 6c eturned on inval
3ca0: 69 64 20 61 72 67 73 2e 3c 2f 6c 69 3e 0d 0a 3c id args.</li>..<
3cb0: 6c 69 3e 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 li><u>Please not
3cc0: 65 3c 2f 75 3e 3a 20 74 68 69 73 20 73 70 65 63 e</u>: this spec
3cd0: 69 66 69 63 20 66 6c 61 76 6f 72 20 6f 66 20 3c ific flavor of <
3ce0: 62 3e 53 54 5f 41 72 65 61 28 29 3c 2f 62 3e 20 b>ST_Area()</b>
3cf0: 6e 65 63 65 73 73 61 72 69 6c 79 20 72 65 71 75 necessarily requ
3d00: 69 72 65 73 20 74 68 65 20 3c 62 3e 4c 57 47 45 ires the <b>LWGE
3d10: 4f 4d 3c 2f 62 3e 20 73 75 70 70 6f 72 74 20 74 OM</b> support t
3d20: 6f 20 62 65 20 61 63 74 69 76 61 74 65 64 20 61 o be activated a
3d30: 74 20 62 75 69 6c 64 20 74 69 6d 65 2e 3c 2f 6c t build time.</l
3d40: 69 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c i>..</ul><br>..<
3d50: 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d hr>..<verbatim>.
3d60: 0a 53 45 4c 45 43 54 20 53 54 5f 41 73 54 65 78 .SELECT ST_AsTex
3d70: 74 28 20 53 54 5f 50 72 6f 6a 65 63 74 28 20 4d t( ST_Project( M
3d80: 61 6b 65 50 6f 69 6e 74 28 20 31 31 2e 35 32 2c akePoint( 11.52,
3d90: 20 34 32 2e 33 38 2c 20 34 33 32 36 20 29 2c 20 42.38, 4326 ),
3da0: 35 30 30 30 30 2c 20 52 61 64 69 61 6e 73 28 20 50000, Radians(
3db0: 34 35 20 29 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 45 ) ) );..-----
3dc0: 2d 2d 2d 2d 2d 0d 0a 50 4f 49 4e 54 28 31 31 2e -----..POINT(11.
3dd0: 39 35 31 34 37 39 20 34 32 2e 36 39 37 34 36 37 951479 42.697467
3de0: 29 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a )..</verbatim>..
3df0: 54 68 65 20 3c 62 3e 53 54 5f 50 72 6f 6a 65 63 The <b>ST_Projec
3e00: 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 t()</b> SQL func
3e10: 74 69 6f 6e 20 77 69 6c 6c 20 72 65 74 75 72 6e tion will return
3e20: 20 74 68 65 20 64 65 73 74 69 6e 61 74 69 6f 6e the destination
3e30: 20 50 6f 69 6e 74 20 3c 75 3e 6f 6e 20 74 68 65 Point <u>on the
3e40: 20 65 6c 6c 69 70 73 6f 69 64 3c 2f 75 3e 20 63 ellipsoid</u> c
3e50: 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 74 6f 20 orresponding to
3e60: 61 20 3c 62 3e 73 74 61 72 74 5f 70 6f 69 6e 74 a <b>start_point
3e70: 3c 2f 62 3e 2c 20 61 20 3c 62 3e 64 69 73 74 61 </b>, a <b>dista
3e80: 6e 63 65 3c 2f 62 3e 20 61 6e 64 20 61 20 3c 62 nce</b> and a <b
3e90: 3e 62 65 61 72 69 6e 67 3c 2f 62 3e 20 28 61 6b >bearing</b> (ak
3ea0: 61 20 3c 75 3e 61 7a 69 6d 75 74 68 3c 2f 75 3e a <u>azimuth</u>
3eb0: 20 61 6b 61 20 3c 75 3e 64 69 72 65 63 74 69 6f aka <u>directio
3ec0: 6e 3c 2f 75 3e 20 61 6b 61 20 3c 75 3e 68 65 61 n</u> aka <u>hea
3ed0: 64 69 6e 67 3c 2f 75 3e 29 2e 0d 0a 3c 75 6c 3e ding</u>)...<ul>
3ee0: 0d 0a 3c 6c 69 3e 74 68 65 20 3c 62 3e 73 74 61 ..<li>the <b>sta
3ef0: 72 74 5f 70 6f 69 6e 74 3c 2f 62 3e 20 69 73 20 rt_point</b> is
3f00: 65 78 70 65 63 74 65 64 20 74 6f 20 61 64 6f 70 expected to adop
3f10: 74 20 3c 75 3e 67 65 6f 67 72 61 70 68 69 63 20 t <u>geographic
3f20: 63 6f 6f 72 64 69 6e 61 74 65 73 3c 2f 75 3e 20 coordinates</u>
3f30: 28 69 2e 65 2e 20 62 61 73 65 64 20 6f 6e 20 3c (i.e. based on <
3f40: 75 3e 6c 6f 6e 67 69 74 75 64 65 3c 2f 75 3e 20 u>longitude</u>
3f50: 61 6e 64 20 3c 75 3e 6c 61 74 69 74 75 64 65 3c and <u>latitude<
3f60: 2f 75 3e 20 61 6e 67 6c 65 73 29 2e 3c 2f 6c 69 /u> angles).</li
3f70: 3e 0d 0a 3c 6c 69 3e 74 68 65 20 3c 62 3e 64 69 >..<li>the <b>di
3f80: 73 74 61 6e 63 65 3c 2f 62 3e 20 69 73 20 61 6c stance</b> is al
3f90: 77 61 79 73 20 65 78 70 65 63 74 65 64 20 74 6f ways expected to
3fa0: 20 62 65 20 65 78 70 72 65 73 73 65 64 20 69 6e be expressed in
3fb0: 20 3c 62 3e 6d 65 74 65 72 73 3c 2f 62 3e 2e 3c <b>meters</b>.<
3fc0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 68 65 20 3c 62 /li>..<li>the <b
3fd0: 3e 61 7a 69 6d 75 74 68 3c 2f 62 3e 20 61 6e 67 >azimuth</b> ang
3fe0: 6c 65 20 69 73 20 65 78 70 65 63 74 65 64 20 74 le is expected t
3ff0: 6f 20 62 65 20 65 78 70 72 65 73 73 65 64 20 69 o be expressed i
4000: 6e 20 3c 62 3e 72 61 64 69 61 6e 73 3c 2f 62 3e n <b>radians</b>
4010: 3a 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 4e 6f 72 :..<ul>..<li>Nor
4020: 74 68 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 th corresponds t
4030: 6f 20 30 20 64 65 67 72 65 65 73 20 28 30 20 72 o 0 degrees (0 r
4040: 61 64 69 61 6e 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c adians).</li>..<
4050: 6c 69 3e 45 61 73 74 20 63 6f 72 72 65 73 70 6f li>East correspo
4060: 6e 64 73 20 74 6f 20 39 30 20 64 65 67 72 65 65 nds to 90 degree
4070: 73 20 28 50 49 2f 32 20 72 61 64 69 61 6e 73 29 s (PI/2 radians)
4080: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 53 6f 75 74 .</li>..<li>Sout
4090: 68 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f h corresponds to
40a0: 20 31 38 30 20 64 65 67 72 65 65 73 20 28 50 49 180 degrees (PI
40b0: 20 72 61 64 69 61 6e 73 29 2e 3c 2f 6c 69 3e 0d radians).</li>.
40c0: 0a 3c 6c 69 3e 57 65 73 74 20 63 6f 72 72 65 73 .<li>West corres
40d0: 70 6f 6e 64 73 20 74 6f 20 32 37 30 20 64 65 67 ponds to 270 deg
40e0: 72 65 65 73 20 28 33 50 49 2f 32 20 72 61 64 69 rees (3PI/2 radi
40f0: 61 6e 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e ans).</li>..<li>
4100: 69 2e 65 2e 20 69 74 20 68 61 73 20 74 68 65 20 i.e. it has the
4110: 73 61 6d 65 20 69 64 65 6e 74 69 63 61 6c 20 6d same identical m
4120: 65 61 6e 69 6e 67 20 61 73 20 69 6e 20 3c 62 3e eaning as in <b>
4130: 53 54 5f 41 7a 69 6d 75 74 68 28 29 3c 2f 62 3e ST_Azimuth()</b>
4140: 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c .</li>..</ul></l
4150: 69 3e 0d 0a 3c 6c 69 3e 74 68 69 73 20 66 75 6e i>..<li>this fun
4160: 63 74 69 6f 6e 20 65 78 61 63 74 6c 79 20 63 6f ction exactly co
4170: 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 74 68 65 rresponds to the
4180: 20 6f 6e 65 20 73 75 70 70 6f 72 74 65 64 20 62 one supported b
4190: 79 20 3c 62 3e 50 6f 73 74 47 49 53 3c 2f 62 3e y <b>PostGIS</b>
41a0: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 75 3e 50 .</li>..<li><u>P
41b0: 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a 20 lease note</u>:
41c0: 3c 62 3e 53 54 5f 50 72 6f 6a 65 63 74 28 29 3c <b>ST_Project()<
41d0: 2f 62 3e 20 6e 65 63 65 73 73 61 72 69 6c 79 20 /b> necessarily
41e0: 72 65 71 75 69 72 65 73 20 74 68 65 20 3c 62 3e requires the <b>
41f0: 4c 57 47 45 4f 4d 3c 2f 62 3e 20 73 75 70 70 6f LWGEOM</b> suppo
4200: 72 74 20 74 6f 20 62 65 20 61 63 74 69 76 61 74 rt to be activat
4210: 65 64 20 61 74 20 62 75 69 6c 64 20 74 69 6d 65 ed at build time
4220: 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 .</li>..</ul><br
4230: 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68 33 3e 3c 61 20 >..<hr>..<h3><a
4240: 6e 61 6d 65 3d 22 75 6e 73 61 66 65 22 3e 55 6e name="unsafe">Un
4250: 73 61 66 65 3c 2f 61 3e 20 28 62 75 74 20 75 73 safe</a> (but us
4260: 65 66 75 6c 29 20 49 6d 70 6f 72 74 2f 45 78 70 eful) Import/Exp
4270: 6f 72 74 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e ort SQL function
4280: 73 3c 2f 68 33 3e 0d 0a 41 6c 6c 20 74 68 65 20 s</h3>..All the
4290: 66 6f 6c 6c 6f 77 69 6e 67 20 53 51 4c 20 66 75 following SQL fu
42a0: 6e 63 74 69 6f 6e 73 20 63 6f 75 6c 64 20 62 65 nctions could be
42b0: 20 72 65 61 6c 6c 79 20 75 73 65 66 75 6c 20 69 really useful i
42c0: 6e 20 6f 72 64 65 72 20 74 6f 20 73 75 70 70 6f n order to suppo
42d0: 72 74 20 49 6d 70 6f 72 74 2f 45 78 70 6f 72 74 rt Import/Export
42e0: 20 6f 70 65 72 61 74 69 6f 6e 73 2e 3c 62 72 3e operations.<br>
42f0: 0d 0a 41 6e 79 77 61 79 20 79 6f 75 20 73 68 6f ..Anyway you sho
4300: 75 6c 64 20 62 65 20 3c 75 3e 77 65 6c 6c 20 61 uld be <u>well a
4310: 77 61 72 65 3c 2f 75 3e 20 74 68 61 74 20 61 6c ware</u> that al
4320: 6c 20 74 68 65 6d 20 63 6f 75 6c 64 20 62 65 20 l them could be
4330: 70 6f 74 65 6e 74 69 61 6c 6c 79 20 3c 75 3e 75 potentially <u>u
4340: 6e 73 61 66 65 3c 2f 75 3e 20 61 6e 64 20 63 6f nsafe</u> and co
4350: 75 6c 64 20 62 65 20 70 6f 74 65 6e 74 69 61 6c uld be potential
4360: 6c 79 20 75 73 65 64 20 62 79 20 73 6f 6d 65 20 ly used by some
4370: 3c 75 3e 6d 61 6c 69 63 69 6f 75 73 20 68 61 63 <u>malicious hac
4380: 6b 65 72 3c 2f 75 3e 20 69 6e 20 6f 72 64 65 72 ker</u> in order
4390: 20 74 6f 20 63 72 65 61 74 65 20 61 6e 64 20 65 to create and e
43a0: 78 70 6c 6f 69 74 20 73 6f 6d 65 20 3c 75 3e 73 xploit some <u>s
43b0: 65 63 75 72 69 74 79 20 62 72 65 61 63 68 3c 2f ecurity breach</
43c0: 75 3e 2e 3c 62 72 3e 0d 0a 54 68 65 20 63 61 75 u>.<br>..The cau
43d0: 73 65 20 69 73 20 76 65 72 79 20 65 61 73 79 20 se is very easy
43e0: 74 6f 20 62 65 20 75 6e 64 65 72 73 74 6f 6f 64 to be understood
43f0: 3a 20 74 68 65 73 65 20 66 75 6e 63 74 69 6f 6e : these function
4400: 73 20 61 6c 6c 6f 77 20 74 6f 20 74 72 61 6e 73 s allow to trans
4410: 66 65 72 20 61 72 62 69 74 72 61 72 79 20 70 61 fer arbitrary pa
4420: 79 6c 6f 61 64 73 20 66 72 6f 6d 20 2f 20 74 6f yloads from / to
4430: 20 74 68 65 20 44 61 74 61 62 61 73 65 20 61 6e the Database an
4440: 64 20 74 68 65 20 6c 6f 63 61 6c 20 46 69 6c 65 d the local File
4450: 2d 53 79 73 74 65 6d 2e 0d 0a 41 20 6d 61 6c 69 -System...A mali
4460: 63 69 6f 75 73 20 61 74 74 61 63 6b 20 63 6f 75 cious attack cou
4470: 6c 64 20 62 65 20 74 68 75 73 20 69 6d 70 6c 65 ld be thus imple
4480: 6d 65 6e 74 65 64 20 65 2e 67 2e 20 62 79 20 65 mented e.g. by e
4490: 78 65 63 75 74 69 6e 67 20 73 6f 6d 65 20 53 51 xecuting some SQ
44a0: 4c 20 73 63 72 69 70 74 20 6f 72 20 62 79 20 64 L script or by d
44b0: 65 66 69 6e 69 6e 67 20 61 20 70 75 72 70 6f 73 efining a purpos
44c0: 65 6c 79 20 66 6f 72 67 65 64 20 54 72 69 67 67 ely forged Trigg
44d0: 65 72 2c 20 61 6e 64 20 74 68 65 20 65 6e 64 20 er, and the end
44e0: 75 73 65 72 73 20 77 6f 75 6c 64 20 62 65 20 61 users would be a
44f0: 62 73 6f 6c 75 74 65 6c 79 20 75 6e 61 77 61 72 bsolutely unawar
4500: 65 20 6f 66 20 77 68 61 74 20 69 73 20 72 65 61 e of what is rea
4510: 6c 6c 79 20 68 61 70 70 65 6e 69 6e 67 2e 0d 0a lly happening...
4520: 53 6f 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 65 So in order to e
4530: 66 66 65 63 74 69 76 65 6c 79 20 73 68 69 65 6c ffectively shiel
4540: 64 20 75 73 65 72 73 20 61 67 61 69 6e 73 74 20 d users against
4550: 74 68 65 73 65 20 70 6f 74 65 6e 74 69 61 6c 6c these potentiall
4560: 79 20 64 61 6e 67 65 72 6f 75 73 20 73 65 63 75 y dangerous secu
4570: 72 69 74 79 20 70 69 74 66 61 6c 6c 73 20 61 6c rity pitfalls al
4580: 6c 20 74 68 65 73 65 20 53 51 4c 20 66 75 6e 63 l these SQL func
4590: 74 69 6f 6e 73 20 61 72 65 20 61 6c 77 61 79 73 tions are always
45a0: 20 3c 75 3e 64 69 73 61 62 6c 65 64 20 62 79 20 <u>disabled by
45b0: 64 65 66 61 75 6c 74 3c 2f 75 3e 2e 0d 0a 3c 76 default</u>...<v
45c0: 65 72 62 61 74 69 6d 3e 0d 0a 65 78 70 6f 72 74 erbatim>..export
45d0: 20 22 53 50 41 54 49 41 4c 49 54 45 5f 53 45 43 "SPATIALITE_SEC
45e0: 55 52 49 54 59 3d 72 65 6c 61 78 65 64 22 0d 0a URITY=relaxed"..
45f0: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 49 6e 20 </verbatim>..In
4600: 6f 72 64 65 72 20 74 6f 20 72 65 61 6c 6c 79 20 order to really
4610: 65 6e 61 62 6c 65 20 74 68 65 73 65 20 66 75 6e enable these fun
4620: 63 74 69 6f 6e 73 20 74 68 65 20 75 73 65 72 20 ctions the user
4630: 69 73 20 72 65 71 75 69 72 65 64 20 74 6f 20 74 is required to t
4640: 61 6b 65 20 61 6e 20 65 78 70 6c 69 63 69 74 20 ake an explicit
4650: 61 63 74 69 6f 6e 3b 20 69 2e 65 2e 20 74 68 65 action; i.e. the
4660: 20 3c 75 3e 65 6e 76 69 72 6f 6e 6d 65 6e 74 20 <u>environment
4670: 76 61 72 69 61 62 6c 65 3c 2f 75 3e 20 3c 62 3e variable</u> <b>
4680: 53 50 41 54 49 41 4c 49 54 45 5f 53 45 43 55 52 SPATIALITE_SECUR
4690: 49 54 59 3d 72 65 6c 61 78 65 64 3c 2f 62 3e 20 ITY=relaxed</b>
46a0: 68 61 73 20 74 6f 20 62 65 20 64 65 66 69 6e 65 has to be define
46b0: 64 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a d...<verbatim>..
46c0: 53 45 4c 45 43 54 20 43 6f 75 6e 74 55 6e 73 61 SELECT CountUnsa
46d0: 66 65 54 72 69 67 67 65 72 73 28 29 3b 0d 0a 2d feTriggers();..-
46e0: 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 30 0d 0a 3c 2f 76 --------..0..</v
46f0: 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 erbatim>..The <b
4700: 3e 43 6f 75 6e 74 55 6e 73 61 66 65 54 72 69 67 >CountUnsafeTrig
4710: 67 65 72 73 28 29 3c 2f 62 3e 20 61 63 74 75 61 gers()</b> actua
4720: 6c 6c 79 20 63 68 65 63 6b 73 20 69 66 20 74 68 lly checks if th
4730: 65 20 63 6f 6e 6e 65 63 74 65 64 20 44 61 74 61 e connected Data
4740: 62 61 73 65 20 64 6f 65 73 20 63 6f 6e 74 61 69 base does contai
4750: 6e 73 20 61 6e 79 20 73 75 73 70 65 63 74 20 54 ns any suspect T
4760: 72 69 67 67 65 72 3b 20 63 68 65 63 6b 69 6e 67 rigger; checking
4770: 20 74 68 69 73 20 76 65 72 73 69 6f 6e 20 62 65 this version be
4780: 66 6f 72 65 20 65 6e 61 62 6c 69 6e 67 20 74 68 fore enabling th
4790: 65 20 75 6e 73 61 66 65 20 53 51 4c 20 46 75 6e e unsafe SQL Fun
47a0: 63 74 69 6f 6e 73 20 69 73 20 61 6c 77 61 79 73 ctions is always
47b0: 20 68 69 67 68 6c 79 20 72 65 63 6f 6d 6d 65 6e highly recommen
47c0: 64 65 64 2e 3c 62 72 3e 0d 0a 41 20 72 65 73 75 ded.<br>..A resu
47d0: 6c 74 20 64 69 66 66 65 72 65 6e 74 20 66 72 6f lt different fro
47e0: 6d 20 5a 45 52 4f 20 69 6d 70 6c 69 65 73 20 74 m ZERO implies t
47f0: 68 61 74 20 73 6f 6d 65 20 6d 61 6c 69 63 69 6f hat some malicio
4800: 75 73 20 54 72 69 67 67 65 72 20 68 61 73 20 62 us Trigger has b
4810: 65 65 6e 20 69 64 65 6e 74 69 66 69 65 64 3b 20 een identified;
4820: 69 6e 20 74 68 69 73 20 63 61 73 65 20 79 6f 75 in this case you
4830: 20 63 61 6e 20 70 65 72 66 6f 72 6d 20 61 20 64 can perform a d
4840: 65 65 70 65 73 74 20 69 6e 73 70 65 63 74 69 6f eepest inspectio
4850: 6e 20 62 79 20 65 78 65 63 75 74 69 6e 67 20 74 n by executing t
4860: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 53 51 4c he following SQL
4870: 20 71 75 65 72 79 3a 0d 0a 3c 76 65 72 62 61 74 query:..<verbat
4880: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 74 79 70 65 im>..SELECT type
4890: 2c 20 6e 61 6d 65 2c 20 74 62 6c 5f 6e 61 6d 65 , name, tbl_name
48a0: 2c 20 73 71 6c 20 0d 0a 46 52 4f 4d 20 73 71 6c , sql ..FROM sql
48b0: 69 74 65 5f 6d 61 73 74 65 72 20 0d 0a 57 48 45 ite_master ..WHE
48c0: 52 45 20 74 79 70 65 20 49 4e 20 28 27 74 72 69 RE type IN ('tri
48d0: 67 67 65 72 27 2c 20 27 76 69 65 77 27 29 20 41 gger', 'view') A
48e0: 4e 44 20 28 73 71 6c 20 4c 49 4b 45 20 27 25 42 ND (sql LIKE '%B
48f0: 6c 6f 62 46 72 6f 6d 46 69 6c 65 25 27 20 0d 0a lobFromFile%' ..
4900: 20 20 20 4f 52 20 73 71 6c 20 4c 49 4b 45 20 27 OR sql LIKE '
4910: 25 42 6c 6f 62 54 6f 46 69 6c 65 25 27 20 4f 52 %BlobToFile%' OR
4920: 20 73 71 6c 20 4c 49 4b 45 20 27 25 58 42 5f 4c sql LIKE '%XB_L
4930: 6f 61 64 58 4d 4c 25 27 20 0d 0a 20 20 20 4f 52 oadXML%' .. OR
4940: 20 73 71 6c 20 4c 49 4b 45 20 27 25 58 42 5f 53 sql LIKE '%XB_S
4950: 74 6f 72 65 58 4d 4c 25 27 29 3b 0d 0a 3c 2f 76 toreXML%');..</v
4960: 65 72 62 61 74 69 6d 3e 0d 0a 74 68 69 73 20 77 erbatim>..this w
4970: 69 6c 6c 20 67 69 76 65 20 61 20 66 75 6c 6c 20 ill give a full
4980: 72 65 70 6f 72 74 20 66 6f 72 20 61 6e 79 20 6d report for any m
4990: 61 6c 69 63 69 6f 75 73 20 54 72 69 67 67 65 72 alicious Trigger
49a0: 20 65 76 65 6e 74 75 61 6c 6c 79 20 66 6f 75 6e eventually foun
49b0: 64 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e d.<br><br>..<hr>
49c0: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 ..<verbatim>..SE
49d0: 4c 45 43 54 20 42 6c 6f 62 46 72 6f 6d 46 69 6c LECT BlobFromFil
49e0: 65 28 20 27 43 3a 2f 6d 79 70 69 63 74 75 72 65 e( 'C:/mypicture
49f0: 73 2f 73 75 6e 73 65 74 2e 6a 70 67 27 20 29 3b s/sunset.jpg' );
4a00: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 42 4c 4f ..---------..BLO
4a10: 42 2d 76 61 6c 75 65 0d 0a 3c 2f 76 65 72 62 61 B-value..</verba
4a20: 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 42 6c 6f tim>..The <b>Blo
4a30: 62 46 72 6f 6d 46 69 6c 65 28 29 3c 2f 62 3e 20 bFromFile()</b>
4a40: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 61 6c 6c SQL function all
4a50: 6f 77 73 20 74 6f 20 69 6d 70 6f 72 74 20 61 20 ows to import a
4a60: 77 68 6f 6c 65 20 66 69 6c 65 20 69 6e 20 61 20 whole file in a
4a70: 73 69 6e 67 6c 65 20 73 74 65 70 3b 20 74 68 65 single step; the
4a80: 20 66 75 6c 6c 20 66 69 6c 65 20 70 61 79 6c 6f full file paylo
4a90: 61 64 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 ad will be retur
4aa0: 6e 65 64 20 61 73 20 61 20 42 4c 4f 42 20 76 61 ned as a BLOB va
4ab0: 6c 75 65 2e 3c 62 72 3e 0d 0a 49 66 20 74 68 65 lue.<br>..If the
4ac0: 20 61 72 67 75 6d 65 6e 74 20 28 3c 62 3e 66 69 argument (<b>fi
4ad0: 6c 65 2d 70 61 74 68 3c 2f 62 3e 29 20 64 6f 65 le-path</b>) doe
4ae0: 73 6e 27 74 20 63 6f 72 72 65 73 70 6f 6e 64 73 sn't corresponds
4af0: 20 74 6f 20 61 20 76 61 6c 69 64 20 66 69 6c 65 to a valid file
4b00: 20 6f 72 20 69 66 20 74 68 65 20 65 78 74 65 72 or if the exter
4b10: 6e 61 6c 20 66 69 6c 65 20 63 61 6e 6e 6f 74 20 nal file cannot
4b20: 62 65 20 61 63 63 65 73 73 65 64 20 66 6f 72 20 be accessed for
4b30: 61 6e 79 20 72 65 61 73 6f 6e 20 4e 55 4c 4c 20 any reason NULL
4b40: 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 will be returned
4b50: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d .<br><br>..<hr>.
4b60: 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c .<verbatim>..SEL
4b70: 45 43 54 20 42 6c 6f 62 54 6f 46 69 6c 65 28 20 ECT BlobToFile(
4b80: 73 6f 6d 65 42 6c 6f 62 20 2c 20 27 43 3a 2f 6d someBlob , 'C:/m
4b90: 79 70 69 63 74 75 72 65 73 2f 73 75 6e 73 65 74 ypictures/sunset
4ba0: 2e 6a 70 67 27 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d .jpg' );..------
4bb0: 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72 62 61 74 ---..1..</verbat
4bc0: 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 42 6c 6f 62 im>..The <b>Blob
4bd0: 54 6f 46 69 6c 65 28 29 3c 2f 62 3e 20 53 51 4c ToFile()</b> SQL
4be0: 20 66 75 6e 63 74 69 6f 6e 20 70 65 72 66 6f 72 function perfor
4bf0: 6d 73 20 74 68 65 20 6f 70 70 6f 73 69 74 65 20 ms the opposite
4c00: 74 61 73 6b 2c 20 69 2e 65 2e 20 69 74 20 65 78 task, i.e. it ex
4c10: 70 6f 72 74 73 20 61 20 77 68 6f 6c 65 20 42 4c ports a whole BL
4c20: 4f 42 20 69 6e 74 6f 20 61 6e 20 65 78 74 65 72 OB into an exter
4c30: 6e 61 6c 20 66 69 6c 65 3b 20 74 68 65 20 66 69 nal file; the fi
4c40: 72 73 74 20 61 72 67 75 6d 65 6e 74 20 6d 75 73 rst argument mus
4c50: 74 20 63 6f 72 72 65 73 70 6f 6e 64 20 74 6f 20 t correspond to
4c60: 73 6f 6d 65 20 42 4c 4f 42 2c 20 74 68 65 20 73 some BLOB, the s
4c70: 65 63 6f 6e 64 20 6f 6e 65 20 69 73 20 74 68 65 econd one is the
4c80: 20 3c 62 3e 66 69 6c 65 2d 70 61 74 68 3c 2f 62 <b>file-path</b
4c90: 3e 20 69 64 65 6e 74 69 66 79 69 6e 67 20 74 68 > identifying th
4ca0: 65 20 66 69 6c 65 20 74 6f 20 62 65 20 63 72 65 e file to be cre
4cb0: 61 74 65 64 20 6f 72 20 6f 76 65 72 77 72 69 74 ated or overwrit
4cc0: 74 65 6e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 75 ten.<br><br>..<u
4cd0: 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e >Please note</u>
4ce0: 3a 20 62 6f 74 68 20 3c 62 3e 42 6c 6f 62 46 72 : both <b>BlobFr
4cf0: 6f 6d 46 69 6c 65 28 29 3c 2f 62 3e 20 61 6e 64 omFile()</b> and
4d00: 20 3c 62 3e 42 6c 6f 62 54 6f 46 69 6c 65 28 29 <b>BlobToFile()
4d10: 3c 2f 62 3e 20 77 65 72 65 20 61 6c 72 65 61 64 </b> were alread
4d20: 79 20 73 75 70 70 6f 72 74 65 64 20 62 79 20 34 y supported by 4
4d30: 2e 30 2e 30 2c 20 62 75 74 20 61 20 71 75 69 63 .0.0, but a quic
4d40: 6b 20 72 65 63 61 6c 6c 20 69 73 20 61 6e 79 77 k recall is anyw
4d50: 61 79 20 75 73 65 66 75 6c 20 73 6f 20 74 6f 20 ay useful so to
4d60: 72 65 63 61 6c 6c 20 61 20 63 6c 65 61 72 65 72 recall a clearer
4d70: 20 63 6f 6e 74 65 78 74 2e 3c 62 72 3e 3c 62 72 context.<br><br
4d80: 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 >..<hr>..<verbat
4d90: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 58 42 5f 4c im>..SELECT XB_L
4da0: 6f 61 64 58 4d 4c 28 20 27 43 3a 2f 6d 79 64 6f oadXML( 'C:/mydo
4db0: 63 73 2f 69 73 6f 6d 65 74 61 64 61 74 61 2d 73 cs/isometadata-s
4dc0: 61 6d 70 6c 65 2e 78 6d 6c 27 20 29 3b 0d 0a 2d ample.xml' );..-
4dd0: 2d 2d 2d 2d 2d 2d 2d 0d 0a 42 4c 4f 42 2d 76 61 -------..BLOB-va
4de0: 6c 75 65 0d 0a 0d 0a 53 45 4c 45 43 54 20 58 42 lue....SELECT XB
4df0: 5f 4c 6f 61 64 58 4d 4c 28 20 27 68 74 74 70 3a _LoadXML( 'http:
4e00: 2f 2f 77 77 77 2e 61 63 6d 65 2e 63 6f 6d 2f 70 //www.acme.com/p
4e10: 75 62 6c 69 63 2f 69 73 6f 6d 65 74 61 64 61 74 ublic/isometadat
4e20: 61 2d 73 61 6d 70 6c 65 2e 78 6d 6c 27 20 29 3b a-sample.xml' );
4e30: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 42 4c 4f 42 ..--------..BLOB
4e40: 2d 76 61 6c 75 65 0d 0a 3c 2f 76 65 72 62 61 74 -value..</verbat
4e50: 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 58 42 5f 4c im>..The <b>XB_L
4e60: 6f 61 64 58 4d 4c 28 29 3c 2f 62 3e 20 53 51 4c oadXML()</b> SQL
4e70: 20 66 75 6e 63 74 69 6f 6e 20 61 6c 6c 6f 77 73 function allows
4e80: 20 74 6f 20 69 6d 70 6f 72 74 20 61 6e 20 58 4d to import an XM
4e90: 4c 20 44 6f 63 75 6d 65 6e 74 20 69 6e 20 61 20 L Document in a
4ea0: 73 69 6e 67 6c 65 20 73 74 65 70 3a 20 74 68 65 single step: the
4eb0: 20 66 75 6c 6c 20 58 4d 4c 20 44 6f 63 75 6d 65 full XML Docume
4ec0: 6e 74 20 70 61 79 6c 6f 61 64 20 77 69 6c 6c 20 nt payload will
4ed0: 62 65 20 72 65 74 75 72 6e 65 64 20 61 73 20 61 be returned as a
4ee0: 20 42 4c 4f 42 20 76 61 6c 75 65 2e 3c 62 72 3e BLOB value.<br>
4ef0: 0d 0a 54 68 65 20 70 61 73 73 65 64 20 61 72 67 ..The passed arg
4f00: 75 6d 65 6e 74 20 63 61 6e 20 69 6e 64 69 66 66 ument can indiff
4f10: 65 72 65 6e 74 6c 79 20 62 65 20 61 20 3c 62 3e erently be a <b>
4f20: 66 69 6c 65 2d 70 61 74 68 3c 2f 62 3e 20 6f 72 file-path</b> or
4f30: 20 61 20 3c 62 3e 55 52 4c 3c 2f 62 3e 3b 20 69 a <b>URL</b>; i
4f40: 66 20 74 68 65 20 64 61 74 61 73 6f 75 72 63 65 f the datasource
4f50: 20 63 61 6e 6e 6f 74 20 62 65 20 61 63 63 65 73 cannot be acces
4f60: 73 65 64 2c 20 6f 72 20 69 66 20 69 74 20 64 6f sed, or if it do
4f70: 65 73 6e 27 74 20 63 6f 6e 74 61 69 6e 73 20 61 esn't contains a
4f80: 20 3c 75 3e 77 65 6c 6c 2d 66 6f 72 6d 65 64 3c <u>well-formed<
4f90: 2f 75 3e 20 58 4d 4c 20 44 6f 63 75 6d 65 6e 74 /u> XML Document
4fa0: 20 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 20 72 65 NULL will be re
4fb0: 74 75 72 6e 65 64 2e 3c 62 72 3e 3c 62 72 3e 0d turned.<br><br>.
4fc0: 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d .<hr>..<verbatim
4fd0: 3e 0d 0a 53 45 4c 45 43 54 20 58 42 5f 53 74 6f >..SELECT XB_Sto
4fe0: 72 65 58 4d 4c 28 20 73 6f 6d 65 58 6d 6c 42 6c reXML( someXmlBl
4ff0: 6f 62 2c 20 27 43 3a 2f 6d 79 64 6f 63 73 2f 69 ob, 'C:/mydocs/i
5000: 73 6f 6d 65 74 61 64 61 74 61 2d 73 61 6d 70 6c sometadata-sampl
5010: 65 2e 78 6d 6c 27 20 29 3b 0d 0a 2d 2d 2d 2d 2d e.xml' );..-----
5020: 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72 62 61 ----..1..</verba
5030: 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 58 42 5f tim>..The <b>XB_
5040: 53 74 6f 72 65 58 4d 4c 28 29 3c 2f 62 3e 20 53 StoreXML()</b> S
5050: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 70 65 72 66 QL function perf
5060: 6f 72 6d 73 20 74 68 65 20 6f 70 70 6f 73 69 74 orms the opposit
5070: 65 20 74 61 73 6b 2c 20 69 2e 65 2e 20 69 74 20 e task, i.e. it
5080: 65 78 70 6f 72 74 73 20 61 20 77 68 6f 6c 65 20 exports a whole
5090: 58 6d 6c 42 4c 4f 42 20 69 6e 74 6f 20 61 6e 20 XmlBLOB into an
50a0: 65 78 74 65 72 6e 61 6c 20 66 69 6c 65 20 61 73 external file as
50b0: 20 61 6e 20 58 4d 4c 20 44 6f 63 75 6d 65 6e 74 an XML Document
50c0: 3b 20 74 68 65 20 66 69 72 73 74 20 61 72 67 75 ; the first argu
50d0: 6d 65 6e 74 20 6d 75 73 74 20 63 6f 72 72 65 73 ment must corres
50e0: 70 6f 6e 64 20 74 6f 20 73 6f 6d 65 20 76 61 6c pond to some val
50f0: 69 64 20 58 6d 6c 42 4c 4f 42 2c 20 74 68 65 20 id XmlBLOB, the
5100: 73 65 63 6f 6e 64 20 6f 6e 65 20 69 73 20 74 68 second one is th
5110: 65 20 3c 62 3e 66 69 6c 65 2d 70 61 74 68 3c 2f e <b>file-path</
5120: 62 3e 20 69 64 65 6e 74 69 66 79 69 6e 67 20 74 b> identifying t
5130: 68 65 20 66 69 6c 65 20 74 6f 20 62 65 20 63 72 he file to be cr
5140: 65 61 74 65 64 20 6f 72 20 6f 76 65 72 77 72 69 eated or overwri
5150: 74 74 65 6e 2e 20 0d 0a 3c 76 65 72 62 61 74 69 tten. ..<verbati
5160: 6d 3e 0d 0a 53 45 4c 45 43 54 20 58 42 5f 53 74 m>..SELECT XB_St
5170: 6f 72 65 58 4d 4c 28 20 73 6f 6d 65 58 6d 6c 42 oreXML( someXmlB
5180: 6c 6f 62 2c 20 27 43 3a 2f 6d 79 64 6f 63 73 2f lob, 'C:/mydocs/
5190: 69 73 6f 6d 65 74 61 64 61 74 61 2d 73 61 6d 70 isometadata-samp
51a0: 6c 65 2e 78 6d 6c 27 2c 20 34 20 29 3b 0d 0a 2d le.xml', 4 );..-
51b0: 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 --------..1..</v
51c0: 65 72 62 61 74 69 6d 3e 0d 0a 41 20 66 75 72 74 erbatim>..A furt
51d0: 68 65 72 20 6f 70 74 69 6f 6e 61 6c 20 3c 62 3e her optional <b>
51e0: 69 6e 64 65 6e 74 61 74 69 6f 6e 3c 2f 62 3e 20 indentation</b>
51f0: 61 72 67 75 6d 65 6e 74 20 63 61 6e 20 62 65 20 argument can be
5200: 65 76 65 6e 74 75 61 6c 6c 79 20 73 70 65 63 69 eventually speci
5210: 66 69 65 64 3b 20 74 68 69 73 20 61 72 67 75 6d fied; this argum
5220: 65 6e 74 20 77 69 6c 6c 20 62 65 20 68 61 6e 64 ent will be hand
5230: 6c 65 64 20 65 78 61 63 74 6c 79 20 69 6e 20 74 led exactly in t
5240: 68 65 20 73 61 6d 65 20 77 61 79 20 61 6c 72 65 he same way alre
5250: 61 64 79 20 73 70 65 63 69 66 69 65 64 20 66 6f ady specified fo
5260: 72 20 62 6f 74 68 20 3c 62 3e 58 42 5f 47 65 74 r both <b>XB_Get
5270: 50 61 79 6c 6f 61 64 28 29 3c 2f 62 3e 20 61 6e Payload()</b> an
5280: 64 20 3c 62 3e 58 42 5f 47 65 74 44 6f 63 75 6d d <b>XB_GetDocum
5290: 65 6e 74 28 29 3c 2f 62 3e 20 66 75 6e 63 74 69 ent()</b> functi
52a0: 6f 6e 73 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 ons.<br><br>..<h
52b0: 72 3e 0d 0a 3c 62 72 3e 41 20 66 75 72 74 68 65 r>..<br>A furthe
52c0: 72 20 3c 75 3e 3c 69 3e 75 6e 73 61 66 65 3c 2f r <u><i>unsafe</
52d0: 69 3e 3c 2f 75 3e 20 53 51 4c 20 66 75 6e 63 74 i></u> SQL funct
52e0: 69 6f 6e 20 69 73 20 3c 62 3e 45 78 70 6f 72 74 ion is <b>Export
52f0: 44 58 46 28 29 3c 2f 62 3e 2c 20 77 68 69 63 68 DXF()</b>, which
5300: 20 69 73 20 73 65 70 61 72 61 74 65 6c 79 20 64 is separately d
5310: 6f 63 75 6d 65 6e 74 65 64 20 69 6e 74 6f 20 74 ocumented into t
5320: 68 65 20 6d 6f 72 65 20 61 70 70 72 6f 70 72 69 he more appropri
5330: 61 74 65 20 3c 61 20 68 72 65 66 3d 22 68 74 74 ate <a href="htt
5340: 70 73 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 ps://www.gaia-gi
5350: 73 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c 69 62 73 s.it/fossil/libs
5360: 70 61 74 69 61 6c 69 74 65 2f 77 69 6b 69 3f 6e patialite/wiki?n
5370: 61 6d 65 3d 44 58 46 22 3e 44 58 46 20 57 69 6b ame=DXF">DXF Wik
5380: 69 20 70 61 67 65 3c 2f 61 3e 2e 3c 62 72 3e 3c i page</a>.<br><
5390: 62 72 3e 0d 0a 3c 68 72 3e 3c 62 72 3e 0d 0a 3c br>..<hr><br>..<
53a0: 61 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f a href="https://
53b0: 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f www.gaia-gis.it/
53c0: 66 6f 73 73 69 6c 2f 6c 69 62 73 70 61 74 69 61 fossil/libspatia
53d0: 6c 69 74 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d 34 lite/wiki?name=4
53e0: 2e 32 2e 30 2d 64 6f 63 22 3e 62 61 63 6b 3c 2f .2.0-doc">back</
53f0: 61 3e 0a 5a 20 32 66 61 30 30 64 36 31 37 62 36 a>.Z 2fa00d617b6
5400: 36 63 32 37 34 31 39 66 61 30 39 61 64 31 35 31 6c27419fa09ad151
5410: 37 62 34 66 66 0a 7b4ff.