Hex Artifact Content
Not logged in

Artifact b5d4c25d3c575223e7c728360edc2cd06fd8216c:

Wiki page [Stored Procedures] by sandro 2017-11-02 22:57:24.
0000: 44 20 32 30 31 37 2d 31 31 2d 30 32 54 32 32 3a  D 2017-11-02T22:
0010: 35 37 3a 32 34 2e 35 31 33 0a 4c 20 53 74 6f 72  57:24.513.L Stor
0020: 65 64 5c 73 50 72 6f 63 65 64 75 72 65 73 0a 50  ed\sProcedures.P
0030: 20 61 30 64 62 35 35 33 37 35 31 31 35 61 63 38   a0db55375115ac8
0040: 63 36 66 66 34 61 31 66 34 35 63 39 33 61 61 34  c6ff4a1f45c93aa4
0050: 33 66 37 61 34 35 62 33 35 0a 55 20 73 61 6e 64  3f7a45b35.U sand
0060: 72 6f 0a 57 20 31 36 37 39 34 0a 3c 74 61 62 6c  ro.W 16794.<tabl
0070: 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 31  e cellspacing="1
0080: 32 22 20 77 69 64 74 68 3d 22 31 30 30 25 22 3e  2" width="100%">
0090: 0d 0a 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61  ..<tr><td colspa
00a0: 6e 3d 22 32 22 3e 0d 0a 3c 74 61 62 6c 65 20 77  n="2">..<table w
00b0: 69 64 74 68 3d 22 31 30 30 25 22 20 62 67 63 6f  idth="100%" bgco
00c0: 6c 6f 72 3d 22 23 66 30 66 30 66 38 22 3e 0d 0a  lor="#f0f0f8">..
00d0: 3c 74 72 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 63  <tr><td align="c
00e0: 65 6e 74 65 72 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f  enter">..</td></
00f0: 74 72 3e 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 74 61  tr></table>..<ta
0100: 62 6c 65 20 77 69 64 74 68 3d 22 31 30 30 25 22  ble width="100%"
0110: 3e 3c 74 72 3e 0d 0a 3c 74 64 20 77 69 64 74 68  ><tr>..<td width
0120: 3d 22 33 33 25 22 20 61 6c 69 67 6e 3d 22 6c 65  ="33%" align="le
0130: 66 74 22 3e 3c 2f 74 64 3e 0d 0a 3c 74 64 20 61  ft"></td>..<td a
0140: 6c 69 67 6e 3d 22 63 65 6e 74 65 72 22 3e 3c 61  lign="center"><a
0150: 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77   href="https://w
0160: 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 66  ww.gaia-gis.it/f
0170: 6f 73 73 69 6c 2f 6c 69 62 73 70 61 74 69 61 6c  ossil/libspatial
0180: 69 74 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d 34 2e  ite/wiki?name=4.
0190: 33 2e 30 2b 64 6f 63 22 3e 62 61 63 6b 20 74 6f  3.0+doc">back to
01a0: 20 69 6e 64 65 78 3c 2f 61 3e 3c 2f 74 64 3e 0d   index</a></td>.
01b0: 0a 3c 74 64 20 77 69 64 74 68 3d 22 33 33 25 22  .<td width="33%"
01c0: 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 3c   align="right"><
01d0: 2f 74 64 3e 0d 0a 3c 2f 74 72 3e 3c 2f 74 61 62  /td>..</tr></tab
01e0: 6c 65 3e 0d 0a 3c 68 31 3e 53 51 4c 20 50 72 6f  le>..<h1>SQL Pro
01f0: 63 65 64 75 72 65 73 2c 20 53 74 6f 72 65 64 20  cedures, Stored 
0200: 50 72 6f 63 65 64 75 72 65 73 20 61 6e 64 20 53  Procedures and S
0210: 74 6f 72 65 64 20 56 61 72 69 61 62 6c 65 73 3a  tored Variables:
0220: 20 61 20 71 75 69 63 6b 20 69 6e 74 72 6f 3c 2f   a quick intro</
0230: 68 31 3e 0d 0a 53 74 61 72 74 69 6e 67 20 73 69  h1>..Starting si
0240: 6e 63 65 20 76 65 72 73 69 6f 6e 20 3c 62 3e 34  nce version <b>4
0250: 2e 35 2e 30 3c 2f 62 3e 20 53 70 61 74 69 61 4c  .5.0</b> SpatiaL
0260: 69 74 65 20 73 75 70 70 6f 72 74 73 20 61 6e 20  ite supports an 
0270: 61 64 76 61 6e 63 65 64 20 6d 65 63 68 61 6e 69  advanced mechani
0280: 73 6d 20 69 6e 74 65 6e 64 65 64 20 74 6f 20 73  sm intended to s
0290: 69 67 6e 69 66 69 63 61 6e 74 6c 79 20 65 78 74  ignificantly ext
02a0: 65 6e 64 20 74 68 65 20 73 63 72 69 70 74 69 6e  end the scriptin
02b0: 67 20 74 65 63 68 6e 69 71 75 65 73 20 61 6c 6c  g techniques all
02c0: 6f 77 69 6e 67 20 66 6f 72 20 61 20 70 6f 77 65  owing for a powe
02d0: 72 66 75 6c 20 61 6e 64 20 66 6c 65 78 69 62 6c  rful and flexibl
02e0: 65 20 61 75 74 6f 6d 61 74 69 6f 6e 20 6f 66 20  e automation of 
02f0: 63 6f 6d 70 6c 65 78 20 77 6f 72 6b 66 6c 6f 77  complex workflow
0300: 73 2e 3c 62 72 3e 0d 0a 54 68 69 6e 6b 20 6f 66  s.<br>..Think of
0310: 20 74 68 65 20 6e 69 63 65 20 66 6c 65 78 69 62   the nice flexib
0320: 69 6c 69 74 79 20 61 6c 6c 6f 77 65 64 20 62 79  ility allowed by
0330: 20 6d 69 78 69 6e 67 20 73 74 61 6e 64 61 72 64   mixing standard
0340: 20 3c 62 3e 3c 69 3e 53 51 4c 20 73 63 72 69 70   <b><i>SQL scrip
0350: 74 73 3c 2f 69 3e 3c 2f 62 3e 20 61 6e 64 20 3c  ts</i></b> and <
0360: 62 3e 3c 69 3e 56 61 72 69 61 62 6c 65 73 3c 2f  b><i>Variables</
0370: 69 3e 3c 2f 62 3e 20 74 6f 20 62 65 20 72 65 70  i></b> to be rep
0380: 6c 61 63 65 64 20 6a 75 73 74 20 62 65 66 6f 72  laced just befor
0390: 65 20 61 63 74 75 61 6c 20 65 78 65 63 75 74 69  e actual executi
03a0: 6f 6e 2e 0d 0a 4e 6f 74 20 6f 6e 6c 79 3a 20 74  on...Not only: t
03b0: 68 69 6e 6b 20 6f 66 20 6d 61 6e 79 20 77 6f 6e  hink of many won
03c0: 64 65 72 66 75 6c 20 6f 70 70 6f 72 74 75 6e 69  derful opportuni
03d0: 74 69 65 73 20 64 65 72 69 76 69 6e 67 20 66 72  ties deriving fr
03e0: 6f 6d 20 70 65 72 6d 61 6e 65 6e 74 6c 79 20 73  om permanently s
03f0: 74 6f 72 69 6e 67 20 77 69 74 68 69 6e 20 61 20  toring within a 
0400: 64 61 74 61 62 61 73 65 20 73 75 63 68 20 3c 62  database such <b
0410: 3e 3c 69 3e 53 51 4c 20 53 63 72 69 70 74 73 20  ><i>SQL Scripts 
0420: 77 69 74 68 20 56 61 72 69 61 62 6c 65 73 3c 2f  with Variables</
0430: 69 3e 3c 2f 62 3e 20 73 6f 20 74 6f 20 6d 61 6b  i></b> so to mak
0440: 65 20 61 73 20 73 69 6d 70 6c 65 20 61 73 20 70  e as simple as p
0450: 6f 73 73 69 62 6c 65 20 61 75 74 6f 6d 61 74 69  ossible automati
0460: 6e 67 20 63 6f 6d 6d 6f 6e 20 77 6f 72 6b 66 6c  ng common workfl
0470: 6f 77 73 20 74 6f 20 62 65 20 72 65 70 65 61 74  ows to be repeat
0480: 65 64 6c 79 20 65 78 65 63 75 74 65 64 2e 0d 0a  edly executed...
0490: 54 68 69 73 20 65 78 61 63 74 6c 79 20 69 73 20  This exactly is 
04a0: 74 68 65 20 69 6e 74 65 6e 64 65 64 20 73 63 6f  the intended sco
04b0: 70 65 20 6f 66 20 74 68 69 73 20 6e 65 77 20 6d  pe of this new m
04c0: 6f 64 75 6c 65 2e 3c 62 72 3e 3c 62 72 3e 0d 0a  odule.<br><br>..
04d0: 57 65 27 6c 6c 20 73 74 61 72 74 20 66 69 72 73  We'll start firs
04e0: 74 20 62 79 20 66 6f 72 6d 61 6c 6c 79 20 64 65  t by formally de
04f0: 66 69 6e 69 6e 67 20 66 65 77 20 62 61 73 69 63  fining few basic
0500: 20 63 6f 6e 63 65 70 74 73 20 61 6e 64 20 6f 62   concepts and ob
0510: 6a 65 63 74 73 20 73 6f 20 74 6f 20 61 76 6f 69  jects so to avoi
0520: 64 20 61 6e 79 20 70 6f 73 73 69 62 6c 65 20 63  d any possible c
0530: 6f 6e 66 75 73 69 6f 6e 2e 3c 62 72 3e 3c 62 72  onfusion.<br><br
0540: 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68 32 3e 42 61 73  >..<hr>..<h2>Bas
0550: 69 63 20 44 65 66 69 6e 69 74 69 6f 6e 73 20 61  ic Definitions a
0560: 6e 64 20 43 6f 6e 63 65 70 74 73 3c 2f 68 32 3e  nd Concepts</h2>
0570: 0d 0a 3c 6f 6c 3e 0d 0a 3c 6c 69 3e 0d 0a 3c 68  ..<ol>..<li>..<h
0580: 34 3e 53 51 4c 20 53 74 61 74 65 6d 65 6e 74 3c  4>SQL Statement<
0590: 2f 68 34 3e 0d 0a 54 68 65 20 6d 69 6e 69 6d 61  /h4>..The minima
05a0: 6c 20 65 78 65 63 75 74 69 6f 6e 20 75 6e 69 74  l execution unit
05b0: 20 61 6c 6c 6f 77 65 64 20 62 79 20 53 51 4c 20   allowed by SQL 
05c0: 73 79 6e 74 61 78 3b 20 61 20 73 74 61 6e 64 2d  syntax; a stand-
05d0: 61 6c 6f 6e 65 20 53 51 4c 20 64 69 72 65 63 74  alone SQL direct
05e0: 69 76 65 20 74 6f 20 62 65 20 61 74 6f 6d 69 63  ive to be atomic
05f0: 61 6c 6c 79 20 65 78 65 63 75 74 65 64 20 69 6e  ally executed in
0600: 20 61 20 73 69 6e 67 6c 65 20 73 74 65 70 2e 20   a single step. 
0610: 45 78 61 6d 70 6c 65 73 3a 0d 0a 3c 76 65 72 62  Examples:..<verb
0620: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 69 64  atim>..SELECT id
0630: 2c 20 6e 61 6d 65 2c 20 6d 65 61 73 75 72 65 20  , name, measure 
0640: 46 52 4f 4d 20 73 6f 6d 65 5f 74 61 62 6c 65 3b  FROM some_table;
0650: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a  ..------------..
0660: 44 45 4c 45 54 45 20 46 52 4f 4d 20 73 6f 6d 65  DELETE FROM some
0670: 5f 74 61 62 6c 65 20 57 48 45 52 45 20 6d 65 61  _table WHERE mea
0680: 73 75 72 65 20 3e 20 31 30 30 30 3b 0d 0a 2d 2d  sure > 1000;..--
0690: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 55 50 44 41  ----------..UPDA
06a0: 54 45 20 73 6f 6d 65 5f 74 61 62 6c 65 20 53 45  TE some_table SE
06b0: 54 20 6d 65 61 73 75 72 65 20 3d 20 6d 65 61 73  T measure = meas
06c0: 75 72 65 20 2f 20 31 30 2e 30 0d 0a 3c 2f 76 65  ure / 10.0..</ve
06d0: 72 62 61 74 69 6d 3e 0d 0a 3c 75 3e 4e 6f 74 65  rbatim>..<u>Note
06e0: 3c 2f 75 3e 3a 20 53 51 4c 20 53 74 61 74 65 6d  </u>: SQL Statem
06f0: 65 6e 74 73 20 61 72 65 20 75 73 75 61 6c 6c 79  ents are usually
0700: 20 65 78 70 65 63 74 65 64 20 74 6f 20 62 65 20   expected to be 
0710: 65 78 70 6c 69 63 69 74 6c 79 20 74 65 72 6d 69  explicitly termi
0720: 6e 61 74 65 64 20 62 79 20 61 20 3c 62 3e 3c 69  nated by a <b><i
0730: 3e 73 65 6d 69 63 6f 6c 6f 6e 3c 2f 69 3e 3c 2f  >semicolon</i></
0740: 62 3e 20 28 3c 62 3e 3c 69 3e 3b 3c 2f 69 3e 3c  b> (<b><i>;</i><
0750: 2f 62 3e 29 2e 3c 62 72 3e 0d 0a 54 68 65 20 73  /b>).<br>..The s
0760: 65 6d 69 63 6f 6c 6f 6e 20 74 65 72 6d 69 6e 61  emicolon termina
0770: 74 6f 72 20 63 61 6e 20 62 65 20 73 61 66 65 6c  tor can be safel
0780: 79 20 73 75 70 70 72 65 73 73 65 64 20 6f 6e 6c  y suppressed onl
0790: 79 20 77 68 65 6e 20 74 68 65 20 53 51 4c 20 53  y when the SQL S
07a0: 74 61 74 65 6d 65 6e 74 20 69 73 20 69 6d 6d 65  tatement is imme
07b0: 64 69 61 74 65 6c 79 20 66 6f 6c 6c 6f 77 65 64  diately followed
07c0: 20 62 79 20 61 20 73 74 72 69 6e 67 20 74 65 72   by a string ter
07d0: 6d 69 6e 61 74 6f 72 20 28 6c 65 61 64 69 6e 67  minator (leading
07e0: 20 61 6e 64 20 74 72 61 69 6c 69 6e 67 20 73 65   and trailing se
07f0: 71 75 65 6e 63 65 73 20 6f 66 20 61 6c 6c 20 3c  quences of all <
0800: 62 3e 3c 69 3e 62 6c 61 6e 6b 73 3c 2f 69 3e 3c  b><i>blanks</i><
0810: 2f 62 3e 20 77 69 6c 6c 20 62 65 20 61 6c 77 61  /b> will be alwa
0820: 79 73 20 69 67 6e 6f 72 65 64 29 2e 0d 0a 3c 62  ys ignored)...<b
0830: 72 3e 3c 62 72 3e 3c 68 72 3e 0d 0a 3c 2f 6c 69  r><br><hr>..</li
0840: 3e 0d 0a 3c 6c 69 3e 0d 0a 3c 68 34 3e 53 51 4c  >..<li>..<h4>SQL
0850: 20 53 63 72 69 70 74 3c 2f 68 34 3e 0d 0a 41 20   Script</h4>..A 
0860: 6d 6f 72 65 20 6f 72 20 6c 65 73 73 20 63 6f 6d  more or less com
0870: 70 6c 65 78 20 73 65 71 75 65 6e 63 65 20 6f 66  plex sequence of
0880: 20 3c 62 3e 3c 69 3e 53 51 4c 20 53 74 61 74 65   <b><i>SQL State
0890: 6d 65 6e 74 73 3c 2f 69 3e 3c 2f 62 3e 2c 20 70  ments</i></b>, p
08a0: 6f 73 73 69 62 6c 79 20 69 6e 63 6c 75 64 69 6e  ossibly includin
08b0: 67 20 69 6e 74 65 72 6c 65 61 76 65 64 20 3c 62  g interleaved <b
08c0: 3e 3c 69 3e 43 6f 6d 6d 65 6e 74 73 3c 2f 69 3e  ><i>Comments</i>
08d0: 3c 2f 62 3e 20 61 6e 64 2f 6f 72 20 3c 62 3e 3c  </b> and/or <b><
08e0: 69 3e 44 6f 74 20 4d 61 63 72 6f 73 3c 2f 69 3e  i>Dot Macros</i>
08f0: 3c 2f 62 3e 2e 3c 62 72 3e 0d 0a 53 51 4c 20 53  </b>.<br>..SQL S
0900: 63 72 69 70 74 73 20 61 72 65 20 69 6e 74 65 6e  cripts are inten
0910: 64 65 64 20 74 6f 20 62 65 20 65 78 65 63 75 74  ded to be execut
0920: 65 64 20 69 6e 20 61 20 73 69 6e 67 6c 65 20 6d  ed in a single m
0930: 6f 6e 6f 6c 69 74 68 69 63 20 70 61 73 73 20 28  onolithic pass (
0940: 61 74 6f 6d 69 63 20 6f 72 20 6e 6f 74 2c 20 64  atomic or not, d
0950: 65 70 65 6e 64 69 6e 67 20 6f 6e 20 69 6e 74 65  epending on inte
0960: 72 6e 61 6c 20 3c 62 3e 3c 69 3e 54 72 61 6e 73  rnal <b><i>Trans
0970: 61 63 74 69 6f 6e 3c 2f 69 3e 3c 2f 62 3e 20 68  action</i></b> h
0980: 61 6e 64 6c 69 6e 67 29 2e 20 45 78 61 6d 70 6c  andling). Exampl
0990: 65 3a 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a  e:..<verbatim>..
09a0: 2e 65 63 68 6f 20 6f 6e 0d 0a 0d 0a 2d 2d 0d 0a  .echo on....--..
09b0: 2d 2d 20 73 74 61 72 74 69 6e 67 20 61 20 54 72  -- starting a Tr
09c0: 61 6e 73 61 63 74 69 6f 6e 0d 0a 2d 2d 0d 0a 42  ansaction..--..B
09d0: 45 47 49 4e 3b 0d 0a 0d 0a 2d 2d 0d 0a 2d 2d 20  EGIN;....--..-- 
09e0: 63 72 65 61 74 69 6e 67 20 61 20 74 61 62 6c 65  creating a table
09f0: 0d 0a 2d 2d 0d 0a 43 52 45 41 54 45 20 54 41 42  ..--..CREATE TAB
0a00: 4c 45 20 65 78 61 6d 70 6c 65 20 28 0d 0a 20 20  LE example (..  
0a10: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  id INTEGER PRIMA
0a20: 52 59 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45  RY KEY AUTOINCRE
0a30: 4d 45 4e 54 2c 0d 0a 20 20 6e 61 6d 65 20 54 45  MENT,..  name TE
0a40: 58 54 20 4e 4f 54 20 4e 55 4c 4c 2c 0d 0a 20 20  XT NOT NULL,..  
0a50: 76 61 6c 75 65 20 44 4f 55 42 4c 45 29 3b 0d 0a  value DOUBLE);..
0a60: 0d 0a 2d 2d 0d 0a 2d 2d 20 70 6f 70 75 6c 61 74  ..--..-- populat
0a70: 69 6e 67 20 74 68 65 20 74 61 62 6c 65 0d 0a 2d  ing the table..-
0a80: 2d 0d 0a 49 4e 53 45 52 54 20 49 4e 54 4f 20 65  -..INSERT INTO e
0a90: 78 61 6d 70 6c 65 20 28 69 64 2c 20 6e 61 6d 65  xample (id, name
0aa0: 2c 20 76 61 6c 75 65 29 20 56 41 4c 55 45 53 20  , value) VALUES 
0ab0: 28 4e 55 4c 4c 2c 20 27 66 69 72 73 74 27 2c 20  (NULL, 'first', 
0ac0: 31 32 2e 33 34 29 3b 0d 0a 49 4e 53 45 52 54 20  12.34);..INSERT 
0ad0: 49 4e 54 4f 20 65 78 61 6d 70 6c 65 20 28 69 64  INTO example (id
0ae0: 2c 20 6e 61 6d 65 2c 20 76 61 6c 75 65 29 20 56  , name, value) V
0af0: 41 4c 55 45 53 20 28 4e 55 4c 4c 2c 20 27 73 65  ALUES (NULL, 'se
0b00: 63 6f 6e 64 27 2c 20 35 36 2e 37 38 29 3b 0d 0a  cond', 56.78);..
0b10: 49 4e 53 45 52 54 20 49 4e 54 4f 20 65 78 61 6d  INSERT INTO exam
0b20: 70 6c 65 20 28 69 64 2c 20 6e 61 6d 65 2c 20 76  ple (id, name, v
0b30: 61 6c 75 65 29 20 56 41 4c 55 45 53 20 28 4e 55  alue) VALUES (NU
0b40: 4c 4c 2c 20 27 74 68 69 72 64 22 2c 20 4e 55 4c  LL, 'third", NUL
0b50: 4c 29 3b 0d 0a 0d 0a 2d 2d 0d 0a 2d 2d 20 63 6f  L);....--..-- co
0b60: 6d 6d 69 74 74 69 6e 67 20 74 68 65 20 70 65 6e  mmitting the pen
0b70: 64 69 6e 67 20 54 72 61 6e 73 61 63 74 69 6f 6e  ding Transaction
0b80: 0d 0a 2d 2d 0d 0a 43 4f 4d 4d 49 54 3b 0d 0a 0d  ..--..COMMIT;...
0b90: 0a 2e 71 75 69 74 0d 0a 3c 2f 76 65 72 62 61 74  ..quit..</verbat
0ba0: 69 6d 3e 0d 0a 3c 68 72 3e 0d 0a 3c 2f 6c 69 3e  im>..<hr>..</li>
0bb0: 0d 0a 3c 6c 69 3e 0d 0a 3c 68 34 3e 53 51 4c 20  ..<li>..<h4>SQL 
0bc0: 56 61 72 69 61 62 6c 65 3c 2f 68 34 3e 0d 0a 41  Variable</h4>..A
0bd0: 20 3c 62 3e 3c 69 3e 53 51 4c 20 56 61 72 69 61   <b><i>SQL Varia
0be0: 62 6c 65 3c 2f 69 3e 3c 2f 62 3e 20 69 73 20 6a  ble</i></b> is j
0bf0: 75 73 74 20 61 20 3c 69 3e 3c 75 3e 6d 6e 65 6d  ust a <i><u>mnem
0c00: 6f 6e 69 63 20 73 79 6d 62 6f 6c 3c 2f 75 3e 3c  onic symbol</u><
0c10: 2f 69 3e 20 65 6e 63 6c 6f 73 65 64 20 62 65 74  /i> enclosed bet
0c20: 77 65 65 6e 20 74 77 6f 20 3c 69 3e 3c 75 3e 73  ween two <i><u>s
0c30: 70 65 63 69 61 6c 20 6d 61 72 6b 65 72 73 3c 2f  pecial markers</
0c40: 75 3e 3c 2f 69 3e 20 28 3c 62 3e 3c 69 3e 40 3c  u></i> (<b><i>@<
0c50: 2f 69 3e 3c 2f 62 3e 20 6f 72 20 3c 62 3e 3c 69  /i></b> or <b><i
0c60: 3e 24 3c 2f 69 3e 3c 2f 62 3e 29 2e 20 45 78 61  >$</i></b>). Exa
0c70: 6d 70 6c 65 73 3a 0d 0a 3c 76 65 72 62 61 74 69  mples:..<verbati
0c80: 6d 3e 0d 0a 40 74 61 62 6c 65 5f 6e 61 6d 65 40  m>..@table_name@
0c90: 0d 0a 40 63 6f 6c 5f 6e 61 6d 65 40 0d 0a 24 76  ..@col_name@..$v
0ca0: 61 6c 75 65 24 0d 0a 24 72 61 64 69 75 73 24 0d  alue$..$radius$.
0cb0: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 75  .</verbatim>..<u
0cc0: 3e 4e 6f 74 65 3c 2f 75 3e 3a 20 75 73 69 6e 67  >Note</u>: using
0cd0: 20 74 68 65 20 3c 62 3e 3c 69 3e 40 3c 2f 69 3e   the <b><i>@</i>
0ce0: 3c 2f 62 3e 20 6f 72 20 74 68 65 20 3c 62 3e 3c  </b> or the <b><
0cf0: 69 3e 24 3c 2f 69 3e 3c 2f 62 3e 20 6d 61 72 6b  i>$</i></b> mark
0d00: 65 72 73 20 69 73 20 6a 75 73 74 20 61 6e 20 3c  ers is just an <
0d10: 69 3e 3c 75 3e 61 65 73 74 68 65 74 69 63 20 63  i><u>aesthetic c
0d20: 68 6f 69 63 65 3c 2f 75 3e 3c 2f 69 3e 3b 20 62  hoice</u></i>; b
0d30: 6f 74 68 20 68 61 76 65 20 69 64 65 6e 74 69 63  oth have identic
0d40: 61 6c 20 6d 65 61 6e 69 6e 67 20 61 6e 64 20 70  al meaning and p
0d50: 72 61 63 74 69 63 61 6c 20 65 66 66 65 63 74 2e  ractical effect.
0d60: 0d 0a 3c 62 72 3e 3c 62 72 3e 3c 68 72 3e 0d 0a  ..<br><br><hr>..
0d70: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 0d 0a 3c 68 34  </li>..<li>..<h4
0d80: 3e 53 51 4c 20 42 6f 64 79 3c 2f 68 34 3e 0d 0a  >SQL Body</h4>..
0d90: 41 20 3c 62 3e 3c 69 3e 53 51 4c 20 53 63 72 69  A <b><i>SQL Scri
0da0: 70 74 3c 2f 69 3e 3c 2f 62 3e 20 69 6e 74 65 72  pt</i></b> inter
0db0: 6e 61 6c 6c 79 20 75 73 69 6e 67 20 3c 62 3e 3c  nally using <b><
0dc0: 69 3e 56 61 72 69 61 62 6c 65 73 3c 2f 69 3e 3c  i>Variables</i><
0dd0: 2f 62 3e 2e 20 45 78 61 6d 70 6c 65 3a 0d 0a 3c  /b>. Example:..<
0de0: 76 65 72 62 61 74 69 6d 3e 0d 0a 2e 65 63 68 6f  verbatim>...echo
0df0: 20 6f 6e 0d 0a 0d 0a 2d 2d 0d 0a 2d 2d 20 73 74   on....--..-- st
0e00: 61 72 74 69 6e 67 20 61 20 54 72 61 6e 73 61 63  arting a Transac
0e10: 74 69 6f 6e 0d 0a 2d 2d 0d 0a 42 45 47 49 4e 3b  tion..--..BEGIN;
0e20: 0d 0a 0d 0a 2d 2d 0d 0a 2d 2d 20 63 72 65 61 74  ....--..-- creat
0e30: 69 6e 67 20 61 20 74 61 62 6c 65 0d 0a 2d 2d 0d  ing a table..--.
0e40: 0a 43 52 45 41 54 45 20 54 41 42 4c 45 20 40 74  .CREATE TABLE @t
0e50: 61 62 6c 65 40 20 28 0d 0a 20 20 40 70 6b 40 20  able@ (..  @pk@ 
0e60: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20  INTEGER PRIMARY 
0e70: 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45 4e  KEY AUTOINCREMEN
0e80: 54 2c 0d 0a 20 20 40 63 6f 6c 31 40 20 54 45 58  T,..  @col1@ TEX
0e90: 54 20 4e 4f 54 20 4e 55 4c 4c 2c 0d 0a 20 20 40  T NOT NULL,..  @
0ea0: 63 6f 6c 32 40 20 44 4f 55 42 4c 45 29 3b 0d 0a  col2@ DOUBLE);..
0eb0: 0d 0a 2d 2d 0d 0a 2d 2d 20 70 6f 70 75 6c 61 74  ..--..-- populat
0ec0: 69 6e 67 20 74 68 65 20 74 61 62 6c 65 0d 0a 2d  ing the table..-
0ed0: 2d 0d 0a 49 4e 53 45 52 54 20 49 4e 54 4f 20 40  -..INSERT INTO @
0ee0: 74 61 62 6c 65 40 20 28 40 70 6b 40 2c 20 40 63  table@ (@pk@, @c
0ef0: 6f 6c 31 40 2c 20 40 63 6f 6c 32 40 29 20 56 41  ol1@, @col2@) VA
0f00: 4c 55 45 53 20 28 4e 55 4c 4c 2c 20 27 66 69 72  LUES (NULL, 'fir
0f10: 73 74 27 2c 20 31 32 2e 33 34 29 3b 0d 0a 49 4e  st', 12.34);..IN
0f20: 53 45 52 54 20 49 4e 54 4f 20 40 74 61 62 6c 65  SERT INTO @table
0f30: 40 20 28 40 70 6b 40 2c 20 40 63 6f 6c 31 40 2c  @ (@pk@, @col1@,
0f40: 20 40 63 6f 6c 32 40 29 20 56 41 4c 55 45 53 20   @col2@) VALUES 
0f50: 28 4e 55 4c 4c 2c 20 27 73 65 63 6f 6e 64 27 2c  (NULL, 'second',
0f60: 20 35 36 2e 37 38 29 3b 0d 0a 49 4e 53 45 52 54   56.78);..INSERT
0f70: 20 49 4e 54 4f 20 40 74 61 62 6c 65 40 20 28 40   INTO @table@ (@
0f80: 70 6b 40 2c 20 40 63 6f 6c 32 40 2c 20 40 63 6f  pk@, @col2@, @co
0f90: 6c 32 40 29 20 56 41 4c 55 45 53 20 28 4e 55 4c  l2@) VALUES (NUL
0fa0: 4c 2c 20 27 74 68 69 72 64 22 2c 20 4e 55 4c 4c  L, 'third", NULL
0fb0: 29 3b 0d 0a 0d 0a 2d 2d 0d 0a 2d 2d 20 63 6f 6d  );....--..-- com
0fc0: 6d 69 74 74 69 6e 67 20 74 68 65 20 70 65 6e 64  mitting the pend
0fd0: 69 6e 67 20 54 72 61 6e 73 61 63 74 69 6f 6e 0d  ing Transaction.
0fe0: 0a 2d 2d 0d 0a 43 4f 4d 4d 49 54 3b 0d 0a 0d 0a  .--..COMMIT;....
0ff0: 2e 71 75 69 74 0d 0a 3c 2f 76 65 72 62 61 74 69  .quit..</verbati
1000: 6d 3e 0d 0a 3c 75 3e 4e 6f 74 65 3c 2f 75 3e 3a  m>..<u>Note</u>:
1010: 20 74 68 69 73 20 73 65 63 6f 6e 64 20 76 65 72   this second ver
1020: 73 69 6f 6e 20 69 73 20 6f 62 76 69 6f 75 73 6c  sion is obviousl
1030: 79 20 6d 6f 72 65 20 66 6c 65 78 69 62 6c 65 20  y more flexible 
1040: 74 68 61 6e 20 74 68 65 20 69 6e 69 74 69 61 6c  than the initial
1050: 20 53 51 4c 20 73 63 72 69 70 74 2c 20 6a 75 73   SQL script, jus
1060: 74 20 62 65 63 61 75 73 65 20 74 68 65 72 65 20  t because there 
1070: 61 72 65 6e 27 74 20 3c 75 3e 3c 69 3e 68 61 72  aren't <u><i>har
1080: 64 77 69 72 65 64 3c 2f 69 3e 3c 2f 75 3e 20 74  dwired</i></u> t
1090: 61 62 6c 65 2d 6e 61 6d 65 73 20 61 6e 64 20 63  able-names and c
10a0: 6f 6c 75 6d 6e 2d 6e 61 6d 65 73 2c 20 61 6c 6c  olumn-names, all
10b0: 20 74 68 65 6d 20 61 72 65 20 6e 6f 77 20 62 65   them are now be
10c0: 63 6f 6d 65 20 3c 75 3e 3c 69 3e 73 79 6d 62 6f  come <u><i>symbo
10d0: 6c 69 63 3c 2f 69 3e 3c 2f 75 3e 2e 3c 62 72 3e  lic</i></u>.<br>
10e0: 0d 0a 53 6f 20 77 65 20 61 72 65 20 6e 6f 77 20  ..So we are now 
10f0: 66 72 65 65 20 74 6f 20 72 65 75 73 65 20 6d 6f  free to reuse mo
1100: 72 65 20 74 69 6d 65 73 20 74 68 69 73 20 53 51  re times this SQ
1110: 4c 20 42 6f 64 79 20 69 6e 20 64 69 66 66 65 72  L Body in differ
1120: 65 6e 74 20 63 6f 6e 74 65 78 74 73 3b 20 77 65  ent contexts; we
1130: 20 6a 75 73 74 20 68 61 76 65 20 74 6f 20 61 70   just have to ap
1140: 70 72 6f 70 72 69 61 74 65 6c 79 20 73 65 74 20  propriately set 
1150: 74 68 65 20 56 61 72 69 61 62 6c 65 20 56 61 6c  the Variable Val
1160: 75 65 73 20 6a 75 73 74 20 69 6d 6d 65 64 69 61  ues just immedia
1170: 74 65 6c 79 20 62 65 66 6f 72 65 20 61 63 74 75  tely before actu
1180: 61 6c 20 65 78 65 63 75 74 69 6f 6e 2e 3c 62 72  al execution.<br
1190: 3e 3c 62 72 3e 0d 0a 3c 62 3e 3c 69 3e 53 51 4c  ><br>..<b><i>SQL
11a0: 20 42 6f 64 69 65 73 3c 2f 69 3e 3c 2f 62 3e 20   Bodies</i></b> 
11b0: 65 78 69 73 74 20 69 6e 20 74 77 6f 20 64 69 66  exist in two dif
11c0: 66 65 72 65 6e 74 20 66 6f 72 6d 73 3a 0d 0a 3c  ferent forms:..<
11d0: 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 72 61 77 3c  ul>..<li><b>raw<
11e0: 2f 62 3e 3a 20 73 74 69 6c 6c 20 69 6e 63 6c 75  /b>: still inclu
11f0: 64 69 6e 67 20 73 79 6d 62 6f 6c 69 63 20 56 61  ding symbolic Va
1200: 72 69 61 62 6c 65 73 2e 3c 2f 6c 69 3e 0d 0a 3c  riables.</li>..<
1210: 6c 69 3e 3c 62 3e 63 6f 6f 6b 65 64 3c 2f 62 3e  li><b>cooked</b>
1220: 3a 20 70 72 65 73 65 6e 74 69 6e 67 20 61 6c 6c  : presenting all
1230: 20 73 79 6d 62 6f 6c 73 20 70 72 6f 70 65 72 6c   symbols properl
1240: 79 20 72 65 70 6c 61 63 65 64 20 62 79 20 74 68  y replaced by th
1250: 65 69 72 20 61 63 74 75 61 6c 20 76 61 6c 75 65  eir actual value
1260: 73 2e 3c 62 72 3e 0d 0a 52 61 74 68 65 72 20 6f  s.<br>..Rather o
1270: 62 76 69 6f 75 73 6c 79 2c 20 79 6f 75 20 63 61  bviously, you ca
1280: 6e 20 73 75 63 63 65 73 73 66 75 6c 6c 79 20 65  n successfully e
1290: 78 65 63 75 74 65 20 6f 6e 6c 79 20 74 68 65 20  xecute only the 
12a0: 3c 62 3e 3c 69 3e 63 6f 6f 6b 65 64 3c 2f 69 3e  <b><i>cooked</i>
12b0: 3c 2f 62 3e 20 66 6f 72 6d 2e 3c 2f 6c 69 3e 0d  </b> form.</li>.
12c0: 0a 3c 2f 75 6c 3e 0d 0a 3c 62 72 3e 3c 68 72 3e  .</ul>..<br><hr>
12d0: 0d 0a 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 0d 0a 3c  ..</li>..<li>..<
12e0: 68 34 3e 53 51 4c 20 50 72 6f 63 65 64 75 72 65  h4>SQL Procedure
12f0: 20 42 4c 4f 42 20 6f 62 6a 65 63 74 3c 2f 68 34   BLOB object</h4
1300: 3e 0d 0a 54 68 69 73 20 73 69 6d 70 6c 79 20 69  >..This simply i
1310: 73 20 61 20 3c 62 3e 3c 69 3e 42 4c 4f 42 20 65  s a <b><i>BLOB e
1320: 6e 63 6f 64 65 64 3c 2f 69 3e 3c 2f 62 3e 20 70  ncoded</i></b> p
1330: 72 65 2d 63 6f 6d 70 69 6c 65 64 20 3c 62 3e 3c  re-compiled <b><
1340: 69 3e 53 51 4c 20 42 6f 64 79 3c 2f 69 3e 3c 2f  i>SQL Body</i></
1350: 62 3e 2c 20 61 6e 64 20 69 73 20 74 68 65 20 75  b>, and is the u
1360: 73 75 61 6c 20 74 61 72 67 65 74 20 65 78 70 65  sual target expe
1370: 63 74 65 64 20 74 6f 20 62 65 20 68 61 6e 64 6c  cted to be handl
1380: 65 64 20 62 79 20 70 72 61 63 74 69 63 61 6c 6c  ed by practicall
1390: 79 20 61 6c 6c 20 53 51 4c 20 66 75 6e 63 74 69  y all SQL functi
13a0: 6f 6e 73 20 73 75 70 70 6f 72 74 69 6e 67 20 53  ons supporting S
13b0: 74 6f 72 65 64 20 50 72 6f 63 65 64 75 72 65 73  tored Procedures
13c0: 20 61 6e 64 20 61 6c 69 6b 65 2e 0d 0a 3c 62 72   and alike...<br
13d0: 3e 3c 62 72 3e 3c 68 72 3e 20 0d 0a 3c 2f 6c 69  ><br><hr> ..</li
13e0: 3e 0d 0a 3c 6c 69 3e 0d 0a 3c 68 34 3e 53 74 6f  >..<li>..<h4>Sto
13f0: 72 65 64 20 50 72 6f 63 65 64 75 72 65 3c 2f 68  red Procedure</h
1400: 34 3e 0d 0a 41 20 3c 62 3e 3c 69 3e 53 51 4c 20  4>..A <b><i>SQL 
1410: 50 72 6f 63 65 64 75 72 65 20 42 4c 4f 42 20 6f  Procedure BLOB o
1420: 62 6a 65 63 74 3c 2f 69 3e 3c 2f 62 3e 20 70 65  bject</i></b> pe
1430: 72 6d 61 6e 65 6e 74 6c 79 20 73 74 6f 72 65 64  rmanently stored
1440: 20 69 6e 74 6f 20 61 20 64 61 74 61 62 61 73 65   into a database
1450: 2e 20 54 68 69 73 20 77 69 6c 6c 20 6d 61 6b 65  . This will make
1460: 20 65 61 73 69 65 72 20 72 65 75 73 69 6e 67 20   easier reusing 
1470: 6d 6f 72 65 20 74 69 6d 65 73 20 74 68 65 20 73  more times the s
1480: 61 6d 65 20 53 51 4c 20 77 6f 72 6b 66 6c 6f 77  ame SQL workflow
1490: 2c 20 70 65 72 68 61 70 73 20 73 6f 20 74 6f 20  , perhaps so to 
14a0: 69 6d 70 6c 65 6d 65 6e 74 20 72 6f 75 74 69 6e  implement routin
14b0: 65 6c 79 20 70 65 72 69 6f 64 69 63 20 74 61 73  ely periodic tas
14c0: 6b 73 20 28 74 6f 20 62 65 20 65 78 65 63 75 74  ks (to be execut
14d0: 65 64 20 64 61 69 6c 79 20 2f 20 77 65 65 6b 6c  ed daily / weekl
14e0: 79 20 2f 20 6d 6f 6e 74 68 6c 79 20 61 6e 64 20  y / monthly and 
14f0: 73 6f 20 6f 6e 29 2e 3c 62 72 3e 0d 0a 53 74 6f  so on).<br>..Sto
1500: 72 65 64 20 50 72 6f 63 65 64 75 72 65 73 20 61  red Procedures a
1510: 6c 77 61 79 73 20 68 61 76 65 20 74 68 65 20 66  lways have the f
1520: 6f 6c 6c 6f 77 69 6e 67 20 65 6c 65 6d 65 6e 74  ollowing element
1530: 73 3a 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 20  s:..<ul>..<li>a 
1540: 3c 62 3e 6e 61 6d 65 3c 2f 62 3e 2c 20 69 6e 74  <b>name</b>, int
1550: 65 6e 64 65 64 20 74 6f 20 62 65 20 61 6e 20 75  ended to be an u
1560: 6e 69 71 75 65 20 69 64 65 6e 74 69 66 69 65 72  nique identifier
1570: 20 28 3c 62 3e 3c 69 3e 50 72 69 6d 61 72 79 20   (<b><i>Primary 
1580: 4b 65 79 3c 2f 69 3e 3c 2f 62 3e 29 2e 3c 2f 6c  Key</i></b>).</l
1590: 69 3e 0d 0a 3c 6c 69 3e 61 20 3c 62 3e 74 69 74  i>..<li>a <b>tit
15a0: 6c 65 3c 2f 62 3e 2c 20 69 2e 65 2e 20 61 20 73  le</b>, i.e. a s
15b0: 68 6f 72 74 20 64 65 73 63 72 69 70 74 69 6f 6e  hort description
15c0: 20 6f 66 20 74 68 65 20 69 6e 74 65 6e 64 65 64   of the intended
15d0: 20 73 63 6f 70 65 20 6f 66 20 74 68 65 20 53 74   scope of the St
15e0: 6f 72 65 64 20 50 72 6f 63 65 64 75 72 65 2e 3c  ored Procedure.<
15f0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 3c 62 3e 53  /li>..<li>a <b>S
1600: 51 4c 20 50 72 6f 63 65 64 75 72 65 20 42 4c 4f  QL Procedure BLO
1610: 42 20 4f 62 6a 65 63 74 3c 2f 62 3e 2e 3c 2f 6c  B Object</b>.</l
1620: 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 62 72 3e 3c  i>..</ul>..<br><
1630: 68 72 3e 0d 0a 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  hr>..</li>..<li>
1640: 0d 0a 3c 68 34 3e 56 61 72 69 61 62 6c 65 20 77  ..<h4>Variable w
1650: 69 74 68 20 56 61 6c 75 65 20 73 74 72 69 6e 67  ith Value string
1660: 73 3c 2f 68 34 3e 0d 0a 42 65 66 6f 72 65 20 65  s</h4>..Before e
1670: 78 65 63 75 74 69 6e 67 20 61 20 3c 62 3e 3c 69  xecuting a <b><i
1680: 3e 53 51 4c 20 42 6f 64 79 3c 2f 69 3e 3c 2f 62  >SQL Body</i></b
1690: 3e 20 69 6e 63 6c 75 64 69 6e 67 20 3c 62 3e 3c  > including <b><
16a0: 69 3e 56 61 72 69 61 62 6c 65 73 3c 2f 69 3e 3c  i>Variables</i><
16b0: 2f 62 3e 20 79 6f 75 20 61 72 65 20 6f 62 76 69  /b> you are obvi
16c0: 6f 75 73 6c 79 20 65 78 70 65 63 74 65 64 20 74  ously expected t
16d0: 6f 20 73 65 74 20 73 6f 6d 65 20 61 70 70 72 6f  o set some appro
16e0: 70 72 69 61 74 65 20 3c 62 3e 3c 69 3e 56 61 6c  priate <b><i>Val
16f0: 75 65 3c 2f 69 3e 3c 2f 62 3e 20 66 6f 72 20 65  ue</i></b> for e
1700: 61 63 68 20 56 61 72 69 61 62 6c 65 2c 20 73 6f  ach Variable, so
1710: 20 74 6f 20 61 6c 6c 6f 77 20 66 6f 72 20 72 65   to allow for re
1720: 70 6c 61 63 69 6e 67 20 3c 75 3e 3c 69 3e 53 79  placing <u><i>Sy
1730: 6d 62 6f 6c 73 3c 2f 69 3e 3c 2f 75 3e 20 77 69  mbols</i></u> wi
1740: 74 68 20 61 63 74 75 61 6c 20 3c 75 3e 3c 69 3e  th actual <u><i>
1750: 56 61 6c 75 65 73 3c 2f 69 3e 3c 2f 75 3e 20 28  Values</i></u> (
1760: 69 2e 65 2e 20 66 6f 72 20 70 72 6f 70 65 72 6c  i.e. for properl
1770: 79 20 74 72 61 6e 73 66 6f 72 6d 69 6e 67 20 3c  y transforming <
1780: 62 3e 72 61 77 3c 2f 62 3e 20 53 51 4c 20 69 6e  b>raw</b> SQL in
1790: 74 6f 20 3c 62 3e 63 6f 6f 6b 65 64 3c 2f 62 3e  to <b>cooked</b>
17a0: 20 53 51 4c 29 2e 3c 62 72 3e 0d 0a 41 20 3c 62   SQL).<br>..A <b
17b0: 3e 3c 69 3e 56 61 72 69 61 62 6c 65 20 77 69 74  ><i>Variable wit
17c0: 68 20 56 61 6c 75 65 3c 2f 69 3e 3c 2f 62 3e 20  h Value</i></b> 
17d0: 73 74 72 69 6e 67 20 73 69 6d 70 6c 79 20 69 73  string simply is
17e0: 20 61 6e 20 61 70 70 72 6f 70 72 69 61 74 65 6c   an appropriatel
17f0: 79 20 77 65 6c 6c 2d 66 6f 72 6d 61 74 74 65 64  y well-formatted
1800: 20 54 65 78 74 20 73 74 72 69 6e 67 20 64 65 63   Text string dec
1810: 6c 61 72 69 6e 67 20 62 6f 74 68 20 74 68 65 20  laring both the 
1820: 53 79 6d 62 6f 6c 20 61 6e 64 20 74 68 65 20 63  Symbol and the c
1830: 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 72 65 70  orresponding rep
1840: 6c 61 63 65 6d 65 6e 74 20 56 61 6c 75 65 20 28  lacement Value (
1850: 65 78 70 72 65 73 73 65 64 20 69 6e 20 69 74 73  expressed in its
1860: 20 74 65 78 74 75 61 6c 20 72 65 70 72 65 73 65   textual represe
1870: 6e 74 61 74 69 6f 6e 29 2e 20 45 78 61 6d 70 6c  ntation). Exampl
1880: 65 73 3a 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d  es:..<verbatim>.
1890: 0a 27 40 76 61 6c 75 65 5f 31 40 3d 31 32 33 34  .'@value_1@=1234
18a0: 27 20 20 20 20 20 20 20 20 20 20 2d 2d 20 69 6e  '          -- in
18b0: 74 65 67 65 72 20 76 61 6c 75 65 0d 0a 27 40 76  teger value..'@v
18c0: 61 6c 75 65 5f 32 40 3d 31 32 2e 33 34 27 20 20  alue_2@=12.34'  
18d0: 20 20 20 20 20 20 20 2d 2d 20 64 6f 75 62 6c 65         -- double
18e0: 20 76 61 6c 75 65 0d 0a 27 40 76 61 6c 75 65 5f   value..'@value_
18f0: 33 40 3d 4e 65 77 20 59 6f 72 6b 20 43 69 74 79  3@=New York City
1900: 27 20 2d 2d 20 74 65 78 74 20 76 61 6c 75 65 0d  ' -- text value.
1910: 0a 27 40 76 61 6c 75 65 5f 34 40 3d 78 27 27 30  .'@value_4@=x''0
1920: 31 32 33 61 62 63 64 27 27 27 20 2d 2d 20 62 6c  123abcd''' -- bl
1930: 6f 62 20 76 61 6c 75 65 0d 0a 27 40 76 61 6c 75  ob value..'@valu
1940: 65 5f 35 40 3d 4e 55 4c 4c 27 20 20 20 20 20 20  e_5@=NULL'      
1950: 20 20 20 20 2d 2d 20 6e 75 6c 6c 20 76 61 6c 75      -- null valu
1960: 65 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  e..</verbatim>..
1970: 3c 74 61 62 6c 65 20 62 67 63 6f 6c 6f 72 3d 22  <table bgcolor="
1980: 23 66 38 66 38 64 38 22 20 63 65 6c 6c 70 61 64  #f8f8d8" cellpad
1990: 64 69 6e 67 3d 22 36 22 20 63 65 6c 6c 73 70 61  ding="6" cellspa
19a0: 63 69 6e 67 3d 22 38 22 3e 3c 74 72 3e 3c 74 64  cing="8"><tr><td
19b0: 3e 0d 0a 3c 75 3e 4e 6f 74 65 3c 2f 75 3e 3a 20  >..<u>Note</u>: 
19c0: 72 65 70 6c 61 63 69 6e 67 20 56 61 72 69 61 62  replacing Variab
19d0: 6c 65 73 20 77 69 74 68 20 61 63 74 75 61 6c 20  les with actual 
19e0: 56 61 6c 75 65 73 20 69 73 20 61 20 62 6c 69 6e  Values is a blin
19f0: 64 20 70 72 6f 63 65 73 73 20 63 6f 6d 70 6c 65  d process comple
1a00: 74 65 6c 79 20 69 6e 73 65 6e 73 69 62 6c 65 20  tely insensible 
1a10: 74 6f 20 74 68 65 20 73 70 65 63 69 66 69 63 20  to the specific 
1a20: 73 79 6e 74 61 63 74 69 63 20 63 6f 6e 74 65 78  syntactic contex
1a30: 74 2e 3c 62 72 3e 0d 0a 59 6f 75 20 61 72 65 20  t.<br>..You are 
1a40: 66 75 6c 6c 79 20 72 65 73 70 6f 6e 73 69 62 6c  fully responsibl
1a50: 65 20 66 6f 72 20 63 6f 72 72 65 63 74 6c 79 20  e for correctly 
1a60: 61 70 70 6c 79 20 73 69 6e 67 6c 65 2d 20 6f 72  apply single- or
1a70: 20 64 6f 75 62 6c 65 2d 71 75 6f 74 69 6e 67 20   double-quoting 
1a80: 77 68 65 72 65 76 65 72 20 72 65 71 75 69 72 65  wherever require
1a90: 64 20 62 79 20 53 51 4c 20 73 79 6e 74 61 78 2e  d by SQL syntax.
1aa0: 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61  ..</td></tr></ta
1ab0: 62 6c 65 3e 0d 0a 3c 62 72 3e 3c 68 72 3e 0d 0a  ble>..<br><hr>..
1ac0: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 0d 0a 3c 68 34  </li>..<li>..<h4
1ad0: 3e 53 74 6f 72 65 64 20 56 61 72 69 61 62 6c 65  >Stored Variable
1ae0: 3c 2f 68 34 3e 0d 0a 41 20 3c 62 3e 3c 69 3e 56  </h4>..A <b><i>V
1af0: 61 72 69 61 62 6c 65 20 77 69 74 68 20 56 61 6c  ariable with Val
1b00: 75 65 20 73 74 72 69 6e 67 3c 2f 69 3e 3c 2f 62  ue string</i></b
1b10: 3e 20 70 65 72 6d 61 6e 65 6e 74 6c 79 20 73 74  > permanently st
1b20: 6f 72 65 64 20 69 6e 74 6f 20 61 20 64 61 74 61  ored into a data
1b30: 62 61 73 65 2e 3c 62 72 3e 0d 0a 53 74 6f 72 65  base.<br>..Store
1b40: 64 20 56 61 72 69 61 62 6c 65 73 20 61 6c 77 61  d Variables alwa
1b50: 79 73 20 68 61 76 65 20 74 68 65 20 66 6f 6c 6c  ys have the foll
1b60: 6f 77 69 6e 67 20 65 6c 65 6d 65 6e 74 73 3a 0d  owing elements:.
1b70: 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 20 3c 62 3e  .<ul>..<li>a <b>
1b80: 6e 61 6d 65 3c 2f 62 3e 2c 20 69 6e 74 65 6e 64  name</b>, intend
1b90: 65 64 20 74 6f 20 62 65 20 61 6e 20 75 6e 69 71  ed to be an uniq
1ba0: 75 65 20 69 64 65 6e 74 69 66 69 65 72 20 28 3c  ue identifier (<
1bb0: 62 3e 3c 69 3e 50 72 69 6d 61 72 79 20 4b 65 79  b><i>Primary Key
1bc0: 3c 2f 69 3e 3c 2f 62 3e 29 2e 3c 2f 6c 69 3e 0d  </i></b>).</li>.
1bd0: 0a 3c 6c 69 3e 61 20 3c 62 3e 74 69 74 6c 65 3c  .<li>a <b>title<
1be0: 2f 62 3e 2c 20 69 2e 65 2e 20 61 20 73 68 6f 72  /b>, i.e. a shor
1bf0: 74 20 64 65 73 63 72 69 70 74 69 6f 6e 20 6f 66  t description of
1c00: 20 74 68 65 20 69 6e 74 65 6e 64 65 64 20 73 63   the intended sc
1c10: 6f 70 65 20 6f 66 20 74 68 65 20 53 74 6f 72 65  ope of the Store
1c20: 64 20 56 61 72 69 61 62 6c 65 2e 3c 2f 6c 69 3e  d Variable.</li>
1c30: 0d 0a 3c 6c 69 3e 61 20 3c 62 3e 56 61 72 69 61  ..<li>a <b>Varia
1c40: 62 6c 65 20 77 69 74 68 20 56 61 6c 75 65 20 73  ble with Value s
1c50: 74 72 69 6e 67 3c 2f 62 3e 2e 3c 2f 6c 69 3e 0d  tring</b>.</li>.
1c60: 0a 3c 2f 75 6c 3e 0d 0a 3c 2f 6c 69 3e 0d 0a 3c  .</ul>..</li>..<
1c70: 2f 6c 69 3e 0d 0a 3c 2f 6f 6c 3e 3c 62 72 3e 0d  /li>..</ol><br>.
1c80: 0a 3c 68 72 3e 0d 0a 3c 68 32 3e 46 61 6d 69 6c  .<hr>..<h2>Famil
1c90: 69 61 72 69 7a 69 6e 67 20 77 69 74 68 20 53 51  iarizing with SQ
1ca0: 4c 20 46 75 6e 63 74 69 6f 6e 73 3c 2f 68 32 3e  L Functions</h2>
1cb0: 0d 0a 3c 6f 6c 3e 0d 0a 3c 6c 69 3e 0d 0a 3c 68  ..<ol>..<li>..<h
1cc0: 34 3e 48 61 6e 64 6c 69 6e 67 20 53 51 4c 20 50  4>Handling SQL P
1cd0: 72 6f 63 65 64 75 72 65 20 42 4c 4f 42 20 6f 62  rocedure BLOB ob
1ce0: 6a 65 63 74 73 3c 2f 68 34 3e 0d 0a 3c 76 65 72  jects</h4>..<ver
1cf0: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53  batim>..SELECT S
1d00: 71 6c 50 72 6f 63 5f 46 72 6f 6d 54 65 78 74 28  qlProc_FromText(
1d10: 27 53 45 4c 45 43 54 20 40 63 6f 6c 40 20 46 52  'SELECT @col@ FR
1d20: 4f 4d 20 40 74 62 6c 40 27 29 3b 0d 0a 0d 0a 53  OM @tbl@');....S
1d30: 45 4c 45 43 54 20 53 71 6c 50 72 6f 63 5f 46 72  ELECT SqlProc_Fr
1d40: 6f 6d 46 69 6c 65 28 27 2f 68 6f 6d 65 2f 6a 6f  omFile('/home/jo
1d50: 65 2f 74 65 6d 70 6c 61 74 65 2e 74 78 74 27 2c  e/template.txt',
1d60: 20 43 50 31 32 35 32 27 29 3b 0d 0a 3c 2f 76 65   CP1252');..</ve
1d70: 72 62 61 74 69 6d 3e 0d 0a 3c 75 6c 3e 0d 0a 3c  rbatim>..<ul>..<
1d80: 6c 69 3e 79 6f 75 20 63 61 6e 20 63 72 65 61 74  li>you can creat
1d90: 65 20 61 20 53 51 4c 20 50 72 6f 63 65 64 75 72  e a SQL Procedur
1da0: 65 20 42 4c 4f 42 20 6f 62 6a 65 63 74 20 62 79  e BLOB object by
1db0: 20 64 69 72 65 63 74 6c 79 20 70 61 73 73 69 6e   directly passin
1dc0: 67 20 61 20 54 65 78 74 20 53 51 4c 20 42 6f 64  g a Text SQL Bod
1dd0: 79 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 6f 72 20  y.</li>..<li>or 
1de0: 61 6c 74 65 72 6e 61 74 69 76 65 6c 79 20 79 6f  alternatively yo
1df0: 75 20 63 61 6e 20 6c 6f 61 64 20 74 68 65 20 53  u can load the S
1e00: 51 4c 20 42 6f 64 79 20 66 72 6f 6d 20 61 6e 20  QL Body from an 
1e10: 65 78 74 65 72 6e 61 6c 20 66 69 6c 65 2e 3c 62  external file.<b
1e20: 72 3e 0d 0a 3c 75 3e 4e 6f 74 65 3c 2f 75 3e 3a  r>..<u>Note</u>:
1e30: 20 74 68 69 73 20 69 73 20 61 20 73 65 63 75 72   this is a secur
1e40: 69 74 79 20 73 65 6e 73 69 62 6c 65 20 6f 70 65  ity sensible ope
1e50: 72 61 74 69 6f 6e 2c 20 73 6f 20 79 6f 75 20 61  ration, so you a
1e60: 6c 77 61 79 73 20 6e 65 65 64 20 74 6f 20 73 65  lways need to se
1e70: 74 20 61 6e 20 65 78 70 6c 69 63 69 74 20 61 75  t an explicit au
1e80: 74 68 6f 72 69 7a 61 74 69 6f 6e 20 62 79 20 64  thorization by d
1e90: 65 66 69 6e 69 6e 67 20 3c 62 3e 53 50 41 54 49  efining <b>SPATI
1ea0: 41 4c 49 54 45 5f 53 45 43 55 52 49 54 59 3d 72  ALITE_SECURITY=r
1eb0: 65 6c 61 78 65 64 3c 2f 62 3e 2e 3c 2f 6c 69 3e  elaxed</b>.</li>
1ec0: 0d 0a 3c 6c 69 3e 42 6f 74 68 20 66 75 6e 63 74  ..<li>Both funct
1ed0: 69 6f 6e 73 20 61 63 63 65 70 74 20 61 6e 20 6f  ions accept an o
1ee0: 70 74 69 6f 6e 61 6c 20 3c 62 3e 63 68 61 72 73  ptional <b>chars
1ef0: 65 74 20 65 6e 63 6f 64 69 6e 67 3c 2f 62 3e 20  et encoding</b> 
1f00: 61 72 67 75 6d 65 6e 74 3b 20 69 6e 20 74 68 69  argument; in thi
1f10: 73 20 63 61 73 65 20 74 68 65 20 53 51 4c 20 42  s case the SQL B
1f20: 6f 64 79 20 77 69 6c 6c 20 62 65 20 61 70 70 72  ody will be appr
1f30: 6f 70 72 69 61 74 65 6c 79 20 63 6f 6e 76 65 72  opriately conver
1f40: 74 65 64 20 66 72 6f 6d 20 74 68 65 20 67 69 76  ted from the giv
1f50: 65 6e 20 63 68 61 72 73 65 74 20 69 6e 74 6f 20  en charset into 
1f60: 3c 62 3e 55 54 46 2d 38 3c 2f 62 3e 2e 3c 2f 6c  <b>UTF-8</b>.</l
1f70: 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 76 65 72 62  i>..</ul>..<verb
1f80: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 71  atim>..SELECT Sq
1f90: 6c 50 72 6f 63 5f 49 73 56 61 6c 69 64 20 28 20  lProc_IsValid ( 
1fa0: 53 71 6c 50 72 6f 63 5f 46 72 6f 6d 54 65 78 74  SqlProc_FromText
1fb0: 28 27 53 45 4c 45 43 54 20 40 63 6f 6c 40 20 46  ('SELECT @col@ F
1fc0: 52 4f 4d 20 40 74 62 6c 40 27 29 20 29 3b 0d 0a  ROM @tbl@') );..
1fd0: 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 0d 0a 53 45 4c 45  -----..1....SELE
1fe0: 43 54 20 53 71 6c 50 72 6f 63 5f 49 73 56 61 6c  CT SqlProc_IsVal
1ff0: 69 64 20 28 20 4d 61 6b 65 50 6f 69 6e 74 28 31  id ( MakePoint(1
2000: 31 2e 35 2c 20 34 32 2e 35 2c 20 34 33 32 36 29  1.5, 42.5, 4326)
2010: 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 30 0d 0a 3c   );..-----..0..<
2020: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 75 6c 3e  /verbatim>..<ul>
2030: 0d 0a 3c 6c 69 3e 79 6f 75 20 63 61 6e 20 75 73  ..<li>you can us
2040: 65 20 3c 62 3e 53 71 6c 50 72 6f 63 5f 49 73 56  e <b>SqlProc_IsV
2050: 61 6c 69 64 3c 2f 62 3e 20 69 6e 20 6f 72 64 65  alid</b> in orde
2060: 72 20 74 6f 20 63 68 65 63 6b 20 69 66 20 61 20  r to check if a 
2070: 67 65 6e 65 72 69 63 20 42 4c 4f 42 20 72 65 61  generic BLOB rea
2080: 6c 6c 79 20 69 73 20 61 20 76 61 6c 69 64 20 53  lly is a valid S
2090: 51 4c 20 50 72 6f 63 65 64 75 72 65 20 42 4c 4f  QL Procedure BLO
20a0: 42 20 4f 62 6a 65 63 74 2e 0d 0a 3c 2f 75 6c 3e  B Object...</ul>
20b0: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45  ..<verbatim>..SE
20c0: 4c 45 43 54 20 53 71 6c 50 72 6f 63 5f 4e 75 6d  LECT SqlProc_Num
20d0: 56 61 72 69 61 62 6c 65 73 20 28 20 53 71 6c 50  Variables ( SqlP
20e0: 72 6f 63 5f 46 72 6f 6d 54 65 78 74 28 27 53 45  roc_FromText('SE
20f0: 4c 45 43 54 20 40 63 6f 6c 40 20 46 52 4f 4d 20  LECT @col@ FROM 
2100: 40 74 62 6c 40 27 29 20 29 3b 0d 0a 2d 2d 2d 2d  @tbl@') );..----
2110: 2d 0d 0a 32 0d 0a 0d 0a 53 45 4c 45 43 54 20 53  -..2....SELECT S
2120: 71 6c 50 72 6f 63 5f 56 61 72 69 61 62 6c 65 4e  qlProc_VariableN
2130: 20 28 53 71 6c 50 72 6f 63 5f 46 72 6f 6d 54 65   (SqlProc_FromTe
2140: 78 74 28 27 53 45 4c 45 43 54 20 40 63 6f 6c 40  xt('SELECT @col@
2150: 20 46 52 4f 4d 20 40 74 62 6c 40 27 29 2c 20 30   FROM @tbl@'), 0
2160: 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 40 63 6f 6c 40  );..-----..@col@
2170: 0d 0a 0d 0a 53 45 4c 45 43 54 20 53 71 6c 50 72  ....SELECT SqlPr
2180: 6f 63 5f 56 61 72 69 61 62 6c 65 4e 20 28 53 71  oc_VariableN (Sq
2190: 6c 50 72 6f 63 5f 46 72 6f 6d 54 65 78 74 28 27  lProc_FromText('
21a0: 53 45 4c 45 43 54 20 40 63 6f 6c 40 20 46 52 4f  SELECT @col@ FRO
21b0: 4d 20 40 74 62 6c 40 27 29 2c 20 31 29 3b 0d 0a  M @tbl@'), 1);..
21c0: 2d 2d 2d 2d 2d 0d 0a 40 74 62 6c 40 0d 0a 0d 0a  -----..@tbl@....
21d0: 53 45 4c 45 43 54 20 53 71 6c 50 72 6f 63 5f 41  SELECT SqlProc_A
21e0: 6c 6c 56 61 72 69 61 62 6c 65 73 20 28 53 71 6c  llVariables (Sql
21f0: 50 72 6f 63 5f 46 72 6f 6d 54 65 78 74 28 27 53  Proc_FromText('S
2200: 45 4c 45 43 54 20 40 63 6f 6c 40 20 46 52 4f 4d  ELECT @col@ FROM
2210: 20 40 74 62 6c 40 27 29 20 29 3b 0d 0a 2d 2d 2d   @tbl@') );..---
2220: 2d 2d 0d 0a 40 63 6f 6c 40 20 40 74 62 6c 40 0d  --..@col@ @tbl@.
2230: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 75  .</verbatim>..<u
2240: 6c 3e 0d 0a 3c 6c 69 3e 79 6f 75 20 63 61 6e 20  l>..<li>you can 
2250: 75 73 65 20 3c 62 3e 53 71 6c 50 72 6f 63 5f 4e  use <b>SqlProc_N
2260: 75 6d 56 61 72 69 61 62 6c 65 73 3c 2f 62 3e 20  umVariables</b> 
2270: 69 6e 20 6f 72 64 65 72 20 74 6f 20 63 68 65 63  in order to chec
2280: 6b 20 68 6f 77 20 6d 61 6e 79 20 56 61 72 69 61  k how many Varia
2290: 62 6c 65 73 20 61 72 65 20 64 65 66 69 6e 65 64  bles are defined
22a0: 20 62 79 20 61 20 53 51 4c 20 50 72 6f 63 65 64   by a SQL Proced
22b0: 75 72 65 20 42 4c 4f 42 20 4f 62 6a 65 63 74 2e  ure BLOB Object.
22c0: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 64 20 79  </li>..<li>and y
22d0: 6f 75 20 63 61 6e 20 75 73 65 20 3c 62 3e 53 71  ou can use <b>Sq
22e0: 6c 50 72 6f 63 5f 56 61 72 69 61 62 6c 65 4e 3c  lProc_VariableN<
22f0: 2f 62 3e 20 69 6e 20 6f 72 64 65 72 20 74 6f 20  /b> in order to 
2300: 72 65 74 72 69 65 76 65 20 61 20 56 61 72 69 61  retrieve a Varia
2310: 62 6c 65 20 4e 61 6d 65 20 62 79 20 73 70 65 63  ble Name by spec
2320: 69 66 79 69 6e 67 20 69 74 73 20 72 65 6c 61 74  ifying its relat
2330: 69 76 65 20 3c 62 3e 49 6e 64 65 78 3c 2f 62 3e  ive <b>Index</b>
2340: 20 28 46 69 72 73 74 20 56 61 72 69 61 62 6c 65   (First Variable
2350: 20 61 6c 77 61 79 73 20 63 6f 72 72 65 73 70 6f   always correspo
2360: 6e 64 73 20 74 6f 20 3c 62 3e 49 6e 64 65 78 3d  nds to <b>Index=
2370: 30 3c 2f 62 3e 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c  0</b>).</li>..<l
2380: 69 3e 61 6e 64 20 66 69 6e 61 6c 6c 79 20 79 6f  i>and finally yo
2390: 75 20 63 61 6e 20 75 73 65 20 3c 62 3e 53 71 6c  u can use <b>Sql
23a0: 50 72 6f 63 5f 41 6c 6c 56 61 72 69 61 62 6c 65  Proc_AllVariable
23b0: 73 3c 2f 62 3e 20 69 6e 20 6f 72 64 65 72 20 74  s</b> in order t
23c0: 6f 20 64 69 72 65 63 74 6c 79 20 67 65 74 20 61  o directly get a
23d0: 6c 6c 20 56 61 72 69 61 62 6c 65 20 4e 61 6d 65  ll Variable Name
23e0: 73 20 66 6f 72 6d 61 74 74 65 64 20 61 73 20 61  s formatted as a
23f0: 20 73 70 61 63 65 2d 73 65 70 61 72 61 74 65 64   space-separated
2400: 20 6c 69 73 74 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75   list.</li>..</u
2410: 6c 3e 0d 0a 3c 62 72 3e 3c 68 72 3e 0d 0a 3c 2f  l>..<br><hr>..</
2420: 6c 69 3e 0d 0a 3c 6c 69 3e 0d 0a 3c 68 34 3e 45  li>..<li>..<h4>E
2430: 72 72 6f 72 20 68 61 6e 64 6c 69 6e 67 3c 2f 68  rror handling</h
2440: 34 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a  4>..<verbatim>..
2450: 53 45 4c 45 43 54 20 53 71 6c 50 72 6f 63 5f 47  SELECT SqlProc_G
2460: 65 74 4c 61 73 74 45 72 72 6f 72 28 29 3b 0d 0a  etLastError();..
2470: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 41 6c 6c  </verbatim>..All
2480: 20 74 68 65 73 65 20 66 75 6e 63 74 69 6f 6e 73   these functions
2490: 20 77 69 6c 6c 20 72 61 69 73 65 20 61 6e 20 45   will raise an E
24a0: 78 63 65 70 74 69 6f 6e 20 6f 6e 20 69 6e 76 61  xception on inva
24b0: 6c 69 64 20 61 72 67 75 6d 65 6e 74 73 20 6f 72  lid arguments or
24c0: 20 65 72 72 6f 72 73 2e 3c 62 72 3e 0d 0a 42 79   errors.<br>..By
24d0: 20 63 61 6c 6c 69 6e 67 20 3c 62 3e 53 71 6c 50   calling <b>SqlP
24e0: 72 6f 63 5f 47 65 74 4c 61 73 74 45 72 72 6f 72  roc_GetLastError
24f0: 3c 2f 62 3e 20 79 6f 75 27 6c 6c 20 75 73 75 61  </b> you'll usua
2500: 6c 6c 79 20 67 65 74 20 61 20 6d 6f 72 65 20 64  lly get a more d
2510: 65 74 61 69 6c 65 64 20 65 78 70 6c 61 6e 61 74  etailed explanat
2520: 69 6f 6e 20 61 62 6f 75 74 20 74 68 65 20 73 70  ion about the sp
2530: 65 63 69 66 69 63 20 63 61 75 73 65 20 61 63 63  ecific cause acc
2540: 6f 75 6e 74 69 6e 67 20 66 6f 72 20 74 68 65 20  ounting for the 
2550: 66 61 69 6c 75 72 65 2e 0d 0a 3c 62 72 3e 3c 62  failure...<br><b
2560: 72 3e 3c 68 72 3e 0d 0a 3c 2f 6c 69 3e 0d 0a 3c  r><hr>..</li>..<
2570: 6c 69 3e 0d 0a 3c 68 34 3e 43 72 65 61 74 69 6e  li>..<h4>Creatin
2580: 67 20 56 61 72 69 61 62 6c 65 73 20 77 69 74 68  g Variables with
2590: 20 56 61 6c 75 65 73 3c 2f 68 34 3e 0d 0a 3c 76   Values</h4>..<v
25a0: 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54  erbatim>..SELECT
25b0: 20 53 71 6c 50 72 6f 63 5f 56 61 72 56 61 6c 75   SqlProc_VarValu
25c0: 65 20 28 27 76 61 72 27 2c 20 4e 55 4c 4c 29 3b  e ('var', NULL);
25d0: 0d 0a 2d 2d 2d 2d 2d 0d 0a 40 76 61 72 40 3d 4e  ..-----..@var@=N
25e0: 55 4c 4c 0d 0a 0d 0a 53 45 4c 45 43 54 20 53 71  ULL....SELECT Sq
25f0: 6c 50 72 6f 63 5f 56 61 72 56 61 6c 75 65 20 28  lProc_VarValue (
2600: 27 76 61 72 27 2c 20 31 29 3b 0d 0a 2d 2d 2d 2d  'var', 1);..----
2610: 2d 0d 0a 40 76 61 72 40 3d 31 0d 0a 0d 0a 53 45  -..@var@=1....SE
2620: 4c 45 43 54 20 53 71 6c 50 72 6f 63 5f 56 61 72  LECT SqlProc_Var
2630: 56 61 6c 75 65 20 28 27 76 61 72 27 2c 20 31 30  Value ('var', 10
2640: 2e 35 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 40 76 61  .5);..-----..@va
2650: 72 40 3d 31 30 2e 35 30 30 30 30 30 30 30 30 0d  r@=10.500000000.
2660: 0a 0d 0a 53 45 4c 45 43 54 20 53 71 6c 50 72 6f  ...SELECT SqlPro
2670: 63 5f 56 61 72 56 61 6c 75 65 20 28 27 76 61 72  c_VarValue ('var
2680: 27 2c 20 27 61 6c 70 68 61 20 62 65 74 61 27 29  ', 'alpha beta')
2690: 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 40 76 61 72 40 3d  ;..-----..@var@=
26a0: 61 6c 70 68 61 20 62 65 74 61 0d 0a 0d 0a 53 45  alpha beta....SE
26b0: 4c 45 43 54 20 53 71 6c 50 72 6f 63 5f 56 61 72  LECT SqlProc_Var
26c0: 56 61 6c 75 65 20 28 27 76 61 72 27 2c 20 4d 61  Value ('var', Ma
26d0: 6b 65 50 6f 69 6e 74 28 31 31 2e 35 2c 20 34 32  kePoint(11.5, 42
26e0: 2e 35 2c 20 34 33 32 36 29 20 29 3b 0d 0a 2d 2d  .5, 4326) );..--
26f0: 2d 2d 2d 0d 0a 40 76 61 72 40 3d 78 27 30 30 30  ---..@var@=x'000
2700: 31 45 36 31 30 30 30 30 30 30 30 30 30 30 30 30  1E61000000000000
2710: 30 30 30 30 30 32 37 34 30 30 30 30 30 30 30 30  0000027400000000
2720: 30 30 30 34 30 34 35 34 30 30 30 30 30 30 30 30  0004045400000000
2730: 30 30 30 30 30 32 37 34 30 30 30 30 30 30 30 30  0000027400000000
2740: 30 30 30 34 30 34 35 34 30 37 43 30 31 30 30 30  0004045407C01000
2750: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 32  0000000000000002
2760: 37 34 30 30 30 30 30 30 30 30 30 30 30 34 30 34  7400000000000404
2770: 35 34 30 46 45 27 0d 0a 3c 2f 76 65 72 62 61 74  540FE'..</verbat
2780: 69 6d 3e 0d 0a 3c 75 3e 4e 6f 74 65 3c 2f 75 3e  im>..<u>Note</u>
2790: 3a 20 68 61 6e 64 20 77 72 69 74 69 6e 67 20 56  : hand writing V
27a0: 61 72 69 61 62 6c 65 20 77 69 74 68 20 56 61 6c  ariable with Val
27b0: 75 65 20 73 74 72 69 6e 67 73 20 69 73 20 61 20  ue strings is a 
27c0: 72 61 74 68 65 72 20 74 72 69 76 69 61 6c 20 6f  rather trivial o
27d0: 70 65 72 61 74 69 6f 6e 2c 20 73 6f 20 63 61 6c  peration, so cal
27e0: 6c 69 6e 67 20 74 68 69 73 20 53 51 4c 20 66 75  ling this SQL fu
27f0: 6e 63 74 69 6f 6e 20 69 73 20 6f 66 74 65 6e 20  nction is often 
2800: 6b 69 6e 64 20 6f 66 20 61 6e 20 6f 76 65 72 6b  kind of an overk
2810: 69 6c 6c 2e 20 45 78 63 65 70 74 2c 20 6d 61 79  ill. Except, may
2820: 20 62 65 2c 20 69 6e 20 74 68 65 20 63 61 73 65   be, in the case
2830: 20 6f 66 20 42 4c 4f 42 20 76 61 6c 75 65 73 2e   of BLOB values.
2840: 0d 0a 3c 62 72 3e 3c 62 72 3e 3c 68 72 3e 0d 0a  ..<br><br><hr>..
2850: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 0d 0a 3c 68 34  </li>..<li>..<h4
2860: 3e 52 61 77 20 61 6e 64 20 43 6f 6f 6b 65 64 20  >Raw and Cooked 
2870: 53 51 4c 20 2d 20 72 65 70 6c 61 63 69 6e 67 20  SQL - replacing 
2880: 53 79 6d 62 6f 6c 73 20 77 69 74 68 20 74 68 65  Symbols with the
2890: 69 72 20 61 63 74 75 61 6c 20 56 61 6c 75 65 73  ir actual Values
28a0: 3c 2f 68 34 3e 0d 0a 3c 76 65 72 62 61 74 69 6d  </h4>..<verbatim
28b0: 3e 0d 0a 53 45 4c 45 43 54 20 53 71 6c 50 72 6f  >..SELECT SqlPro
28c0: 63 5f 52 61 77 53 51 4c 20 28 20 53 71 6c 50 72  c_RawSQL ( SqlPr
28d0: 6f 63 5f 46 72 6f 6d 54 65 78 74 28 27 53 45 4c  oc_FromText('SEL
28e0: 45 43 54 20 40 63 6f 6c 40 20 46 52 4f 4d 20 40  ECT @col@ FROM @
28f0: 74 62 6c 40 3b 27 29 20 29 3b 0d 0a 2d 2d 2d 2d  tbl@;') );..----
2900: 2d 0d 0a 53 45 4c 45 43 54 20 40 63 6f 6c 40 20  -..SELECT @col@ 
2910: 46 52 4f 4d 20 40 74 62 6c 40 3b 0d 0a 0d 0a 53  FROM @tbl@;....S
2920: 45 4c 45 43 54 20 53 71 6c 50 72 6f 63 5f 43 6f  ELECT SqlProc_Co
2930: 6f 6b 65 64 53 51 4c 20 28 20 53 71 6c 50 72 6f  okedSQL ( SqlPro
2940: 63 5f 46 72 6f 6d 54 65 78 74 28 27 53 45 4c 45  c_FromText('SELE
2950: 43 54 20 40 63 6f 6c 40 20 46 52 4f 4d 20 40 74  CT @col@ FROM @t
2960: 62 6c 40 3b 27 29 2c 0d 0a 20 20 20 20 27 40 63  bl@;'),..    '@c
2970: 6f 6c 40 3d 66 69 72 73 74 5f 6e 61 6d 65 27 2c  ol@=first_name',
2980: 0d 0a 20 20 20 20 27 40 74 62 6c 40 3d 70 68 6f  ..    '@tbl@=pho
2990: 6e 65 5f 62 6f 6f 6b 27 20 29 3b 0d 0a 2d 2d 2d  ne_book' );..---
29a0: 2d 2d 0d 0a 53 45 4c 45 43 54 20 66 69 72 73 74  --..SELECT first
29b0: 5f 6e 61 6d 65 20 46 52 4f 4d 20 70 68 6f 6e 65  _name FROM phone
29c0: 5f 62 6f 6f 6b 3b 0d 0a 3c 2f 76 65 72 62 61 74  _book;..</verbat
29d0: 69 6d 3e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 79  im>..<ul>..<li>y
29e0: 6f 75 20 63 61 6e 20 75 73 65 20 3c 62 3e 53 71  ou can use <b>Sq
29f0: 6c 50 72 6f 63 5f 52 61 77 53 51 4c 3c 2f 62 3e  lProc_RawSQL</b>
2a00: 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 64 69 72   in order to dir
2a10: 65 63 74 6c 79 20 63 68 65 63 6b 20 74 68 65 20  ectly check the 
2a20: 53 51 4c 20 42 6f 64 79 20 65 6e 63 61 70 73 75  SQL Body encapsu
2a30: 6c 61 74 65 64 20 69 6e 74 6f 20 73 20 53 51 4c  lated into s SQL
2a40: 20 50 72 6f 63 65 64 75 72 65 20 42 4c 4f 42 20   Procedure BLOB 
2a50: 4f 62 6a 65 63 74 3b 20 61 6c 6c 20 69 6e 69 74  Object; all init
2a60: 69 61 6c 20 56 61 72 69 61 62 6c 65 20 64 65 66  ial Variable def
2a70: 69 6e 69 74 69 6f 6e 73 20 77 69 6c 6c 20 62 65  initions will be
2a80: 20 63 61 72 65 66 75 6c 6c 79 20 70 72 65 73 65   carefully prese
2a90: 72 76 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  rved.</li>..<li>
2aa0: 61 6e 64 20 79 6f 75 20 63 61 6e 20 75 73 65 20  and you can use 
2ab0: 3c 62 3e 53 71 6c 50 72 6f 63 5f 43 6f 6f 6b 65  <b>SqlProc_Cooke
2ac0: 64 53 51 4c 3c 2f 62 3e 20 69 6e 20 6f 72 64 65  dSQL</b> in orde
2ad0: 72 20 74 6f 20 64 69 72 65 63 74 6c 79 20 63 68  r to directly ch
2ae0: 65 63 6b 20 74 68 65 20 53 51 4c 20 42 6f 64 79  eck the SQL Body
2af0: 20 61 73 20 69 74 20 61 63 74 75 61 6c 6c 79 20   as it actually 
2b00: 61 70 70 65 61 72 73 20 61 66 74 65 72 20 72 65  appears after re
2b10: 70 6c 61 63 69 6e 67 20 61 6c 6c 20 72 65 71 75  placing all requ
2b20: 69 72 65 64 20 56 61 72 69 61 62 6c 65 20 56 61  ired Variable Va
2b30: 6c 75 65 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  lues.</li>..<li>
2b40: 42 6f 74 68 20 66 75 6e 63 74 69 6f 6e 73 20 61  Both functions a
2b50: 72 65 20 6d 61 69 6e 6c 79 20 69 6e 74 65 6e 64  re mainly intend
2b60: 65 64 20 66 6f 72 20 73 75 70 70 6f 72 74 69 6e  ed for supportin
2b70: 67 20 64 65 62 75 67 67 69 6e 67 20 61 63 74 69  g debugging acti
2b80: 76 69 74 69 65 73 2c 20 73 6f 20 74 6f 20 6d 61  vities, so to ma
2b90: 6b 65 20 61 73 20 65 61 73 79 20 61 73 20 70 6f  ke as easy as po
2ba0: 73 73 69 62 6c 65 20 69 64 65 6e 74 69 66 79 69  ssible identifyi
2bb0: 6e 67 20 65 76 65 6e 74 75 61 6c 20 65 72 72 6f  ng eventual erro
2bc0: 72 73 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c  rs.</li>..</ul><
2bd0: 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f  br>..<table bgco
2be0: 6c 6f 72 3d 22 23 66 38 66 38 64 38 22 20 63 65  lor="#f8f8d8" ce
2bf0: 6c 6c 70 61 64 64 69 6e 67 3d 22 36 22 20 63 65  llpadding="6" ce
2c00: 6c 6c 73 70 61 63 69 6e 67 3d 22 38 22 3e 3c 74  llspacing="8"><t
2c10: 72 3e 3c 74 64 3e 0d 0a 3c 75 3e 4e 6f 74 65 3c  r><td>..<u>Note<
2c20: 2f 75 3e 3a 20 3c 62 3e 53 71 6c 50 72 6f 63 5f  /u>: <b>SqlProc_
2c30: 43 6f 6f 6b 65 64 53 51 4c 3c 2f 62 3e 20 77 69  CookedSQL</b> wi
2c40: 6c 6c 20 61 63 63 65 70 74 20 61 6e 20 61 72 62  ll accept an arb
2c50: 69 74 72 61 72 79 20 6c 69 73 74 20 6f 66 20 3c  itrary list of <
2c60: 62 3e 56 61 72 69 61 62 6c 65 20 77 69 74 68 20  b>Variable with 
2c70: 56 61 6c 75 65 3c 2f 62 3e 20 61 72 67 75 6d 65  Value</b> argume
2c80: 6e 74 73 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e  nts...<ul>..<li>
2c90: 61 6e 20 65 6d 70 74 79 20 6c 69 73 74 20 28 6e  an empty list (n
2ca0: 6f 20 56 61 72 69 61 62 6c 65 73 20 77 69 74 68  o Variables with
2cb0: 20 56 61 6c 75 65 73 20 61 74 20 61 6c 6c 29 20   Values at all) 
2cc0: 69 73 20 61 20 70 65 72 66 65 63 74 6c 79 20 6c  is a perfectly l
2cd0: 65 67 61 6c 20 63 6f 6e 64 69 74 69 6f 6e 20 28  egal condition (
2ce0: 63 6f 75 6c 64 20 65 76 65 6e 74 75 61 6c 6c 79  could eventually
2cf0: 20 6c 65 61 64 20 74 6f 20 61 6e 20 69 6e 76 61   lead to an inva
2d00: 6c 69 64 20 43 6f 6f 6b 65 64 20 53 51 4c 20 42  lid Cooked SQL B
2d10: 6f 64 79 2c 20 73 65 65 20 62 65 6c 6f 77 29 2e  ody, see below).
2d20: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6c 6c 20 61  </li>..<li>all a
2d30: 72 67 75 6d 65 6e 74 73 20 66 72 6f 6d 20 74 68  rguments from th
2d40: 65 20 73 65 63 6f 6e 64 20 75 6e 74 69 6c 20 74  e second until t
2d50: 68 65 20 65 6e 64 20 61 72 65 20 65 78 70 65 63  he end are expec
2d60: 74 65 64 20 74 6f 20 62 65 20 77 65 6c 6c 2d 66  ted to be well-f
2d70: 6f 72 6d 65 64 20 56 61 72 69 61 62 6c 65 73 20  ormed Variables 
2d80: 77 69 74 68 20 56 61 6c 75 65 73 2e 3c 2f 6c 69  with Values.</li
2d90: 3e 0d 0a 3c 6c 69 3e 79 6f 75 20 63 61 6e 20 64  >..<li>you can d
2da0: 65 66 69 6e 65 20 61 73 20 6d 75 63 68 20 61 73  efine as much as
2db0: 20 3c 62 3e 31 36 3c 2f 62 3e 20 64 69 66 66 65   <b>16</b> diffe
2dc0: 72 65 6e 74 20 56 61 72 69 61 62 6c 65 73 20 77  rent Variables w
2dd0: 69 74 68 20 56 61 6c 75 65 73 2e 3c 2f 6c 69 3e  ith Values.</li>
2de0: 0d 0a 3c 6c 69 3e 61 6e 79 20 61 74 74 65 6d 70  ..<li>any attemp
2df0: 74 20 74 6f 20 64 65 66 69 6e 65 20 74 77 69 63  t to define twic
2e00: 65 20 61 20 56 61 6c 75 65 20 66 6f 72 20 74 68  e a Value for th
2e10: 65 20 73 61 6d 65 20 56 61 72 69 61 62 6c 65 20  e same Variable 
2e20: 77 69 6c 6c 20 62 65 20 61 6c 77 61 79 73 20 63  will be always c
2e30: 6f 6e 73 69 64 65 72 65 64 20 61 73 20 61 20 66  onsidered as a f
2e40: 61 74 61 6c 20 65 72 72 6f 72 2e 3c 2f 6c 69 3e  atal error.</li>
2e50: 0d 0a 3c 6c 69 3e 69 66 20 6f 6e 65 20 6f 66 20  ..<li>if one of 
2e60: 74 68 65 20 56 61 72 69 61 62 6c 65 20 61 72 67  the Variable arg
2e70: 75 6d 65 6e 74 73 20 64 6f 65 73 20 6e 6f 74 20  uments does not 
2e80: 6d 61 74 63 68 20 6f 6e 65 20 74 68 65 20 56 61  match one the Va
2e90: 72 69 61 62 6c 65 73 20 69 6e 74 65 72 6e 61 6c  riables internal
2ea0: 6c 79 20 64 65 66 69 6e 65 64 20 62 79 20 74 68  ly defined by th
2eb0: 65 20 52 61 77 20 53 51 4c 20 42 6f 64 79 20 69  e Raw SQL Body i
2ec0: 74 20 77 69 6c 6c 20 62 65 20 73 69 6d 70 6c 79  t will be simply
2ed0: 20 69 67 6e 6f 72 65 64 2e 3c 2f 6c 69 3e 0d 0a   ignored.</li>..
2ee0: 3c 6c 69 3e 69 66 20 61 20 56 61 72 69 61 62 6c  <li>if a Variabl
2ef0: 65 20 64 65 66 69 6e 65 64 20 69 6e 74 6f 20 74  e defined into t
2f00: 68 65 20 52 61 77 20 53 51 4c 20 42 6f 64 79 20  he Raw SQL Body 
2f10: 64 6f 65 73 20 6e 6f 74 20 6d 61 74 63 68 65 73  does not matches
2f20: 20 61 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67   a corresponding
2f30: 20 56 61 72 69 61 62 6c 65 20 61 72 67 75 6d 65   Variable argume
2f40: 6e 74 20 74 68 65 6e 20 69 74 20 77 69 6c 6c 20  nt then it will 
2f50: 72 65 70 6c 61 63 65 64 20 62 79 20 61 20 64 65  replaced by a de
2f60: 66 61 75 6c 74 20 27 3c 62 3e 4e 55 4c 4c 3c 2f  fault '<b>NULL</
2f70: 62 3e 27 20 73 74 72 69 6e 67 2e 3c 2f 6c 69 3e  b>' string.</li>
2f80: 0d 0a 3c 6c 69 3e 74 68 65 20 73 61 6d 65 20 69  ..<li>the same i
2f90: 64 65 6e 74 69 63 61 6c 20 72 75 6c 65 73 20 66  dentical rules f
2fa0: 6f 72 20 70 61 73 73 69 6e 67 20 56 61 72 69 61  or passing Varia
2fb0: 62 6c 65 2d 56 61 6c 75 65 20 61 72 67 75 6d 65  ble-Value argume
2fc0: 6e 74 73 20 61 70 70 6c 79 20 74 6f 20 3c 62 3e  nts apply to <b>
2fd0: 53 71 6c 50 72 6f 63 5f 43 6f 6f 6b 65 64 53 51  SqlProc_CookedSQ
2fe0: 4c 3c 2f 62 3e 2c 20 3c 62 3e 53 71 6c 50 72 6f  L</b>, <b>SqlPro
2ff0: 63 5f 45 78 65 63 75 74 65 3c 2f 62 3e 20 61 6e  c_Execute</b> an
3000: 64 20 3c 62 3e 53 74 6f 72 65 64 50 72 6f 63 5f  d <b>StoredProc_
3010: 45 78 65 63 75 74 65 3c 2f 62 3e 2e 3c 2f 6c 69  Execute</b>.</li
3020: 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 2f 74 64 3e 3c  >..</ul>..</td><
3030: 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62  /tr></table>..<b
3040: 72 3e 3c 68 72 3e 0d 0a 3c 2f 6c 69 3e 0d 0a 3c  r><hr>..</li>..<
3050: 6c 69 3e 0d 0a 3c 68 34 3e 45 78 65 63 75 74 69  li>..<h4>Executi
3060: 6e 67 20 61 20 53 51 4c 20 50 72 6f 63 65 64 75  ng a SQL Procedu
3070: 72 65 3c 2f 68 34 3e 0d 0a 3c 76 65 72 62 61 74  re</h4>..<verbat
3080: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 71 6c 50  im>..SELECT SqlP
3090: 72 6f 63 5f 45 78 65 63 75 74 65 20 28 53 71 6c  roc_Execute (Sql
30a0: 50 72 6f 63 5f 46 72 6f 6d 54 65 78 74 28 27 53  Proc_FromText('S
30b0: 45 4c 45 43 54 20 40 63 6f 6c 40 20 46 52 4f 4d  ELECT @col@ FROM
30c0: 20 40 74 62 6c 40 3b 27 29 2c 0d 0a 20 20 20 20   @tbl@;'),..    
30d0: 27 40 63 6f 6c 40 3d 66 69 72 73 74 5f 6e 61 6d  '@col@=first_nam
30e0: 65 27 2c 0d 0a 20 20 20 20 27 40 74 62 6c 40 3d  e',..    '@tbl@=
30f0: 70 68 6f 6e 65 5f 62 6f 6f 6b 27 20 29 3b 0d 0a  phone_book' );..
3100: 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72 62  -----..1..</verb
3110: 61 74 69 6d 3e 0d 0a 79 6f 75 20 63 61 6e 20 75  atim>..you can u
3120: 73 65 20 3c 62 3e 53 71 6c 50 72 6f 63 5f 45 78  se <b>SqlProc_Ex
3130: 65 63 75 74 65 3c 2f 62 3e 20 69 6e 20 6f 72 64  ecute</b> in ord
3140: 65 72 20 74 6f 20 64 69 72 65 63 74 6c 79 20 65  er to directly e
3150: 78 65 63 75 74 65 20 74 68 65 20 77 68 6f 6c 65  xecute the whole
3160: 20 53 51 4c 20 42 6f 64 79 20 61 73 20 61 20 73   SQL Body as a s
3170: 69 6e 67 6c 65 20 6d 6f 6e 6f 6c 69 74 68 69 63  ingle monolithic
3180: 20 75 6e 69 74 2e 3c 62 72 3e 0d 0a 41 74 20 74   unit.<br>..At t
3190: 68 65 20 65 6e 64 20 6f 66 20 74 68 65 20 70 72  he end of the pr
31a0: 6f 63 65 73 73 20 3c 62 3e 31 3c 2f 62 3e 20 28  ocess <b>1</b> (
31b0: 61 6b 61 20 3c 62 3e 54 72 75 65 3c 2f 62 3e 29  aka <b>True</b>)
31c0: 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65   will be returne
31d0: 64 20 6f 6e 20 66 75 6c 6c 20 73 75 63 63 65 73  d on full succes
31e0: 73 3b 20 61 6e 20 45 78 63 65 70 74 69 6f 6e 20  s; an Exception 
31f0: 77 69 6c 6c 20 62 65 20 72 61 69 73 65 64 20 6f  will be raised o
3200: 6e 20 66 61 69 6c 75 72 65 2e 3c 62 72 3e 3c 62  n failure.<br><b
3210: 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f 6c  r>..<table bgcol
3220: 6f 72 3d 22 23 66 38 66 38 64 38 22 20 63 65 6c  or="#f8f8d8" cel
3230: 6c 70 61 64 64 69 6e 67 3d 22 36 22 20 63 65 6c  lpadding="6" cel
3240: 6c 73 70 61 63 69 6e 67 3d 22 38 22 3e 3c 74 72  lspacing="8"><tr
3250: 3e 3c 74 64 3e 0d 0a 3c 75 3e 4e 6f 74 65 3c 2f  ><td>..<u>Note</
3260: 75 3e 3a 20 61 6c 6c 20 3c 62 3e 44 6f 74 20 4d  u>: all <b>Dot M
3270: 61 63 72 6f 73 3c 2f 62 3e 20 65 76 65 6e 74 75  acros</b> eventu
3280: 61 6c 6c 79 20 66 6f 75 6e 64 20 77 69 74 68 69  ally found withi
3290: 6e 20 74 68 65 20 53 51 4c 20 42 6f 64 79 20 62  n the SQL Body b
32a0: 65 69 6e 67 20 65 78 65 63 75 74 65 64 20 77 69  eing executed wi
32b0: 6c 6c 20 62 65 20 61 6c 77 61 79 73 20 73 69 6c  ll be always sil
32c0: 65 6e 74 6c 79 20 69 67 6e 6f 72 65 64 2e 3c 62  ently ignored.<b
32d0: 72 3e 0d 0a 54 68 65 20 73 61 6d 65 20 72 75 6c  r>..The same rul
32e0: 65 20 61 70 70 6c 69 65 73 20 74 6f 20 3c 62 3e  e applies to <b>
32f0: 53 74 6f 72 65 64 50 72 6f 63 5f 45 78 65 63 75  StoredProc_Execu
3300: 74 65 3c 2f 62 3e 20 61 73 20 77 65 6c 6c 2e 3c  te</b> as well.<
3310: 2f 62 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c  /b>..</td></tr><
3320: 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e 3c 68 72  /table>..<br><hr
3330: 3e 0d 0a 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 0d 0a  >..</li>..<li>..
3340: 3c 68 34 3e 48 61 6e 64 6c 69 6e 67 20 53 51 4c  <h4>Handling SQL
3350: 20 53 74 6f 72 65 64 20 50 72 6f 63 65 64 75 72   Stored Procedur
3360: 65 73 3c 2f 68 34 3e 0d 0a 3c 76 65 72 62 61 74  es</h4>..<verbat
3370: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 74 6f 72  im>..SELECT Stor
3380: 65 64 50 72 6f 63 5f 43 72 65 61 74 65 54 61 62  edProc_CreateTab
3390: 6c 65 73 28 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 31  les();..-----..1
33a0: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 79  ..</verbatim>..y
33b0: 6f 75 20 63 61 6e 20 75 73 65 20 3c 62 3e 53 74  ou can use <b>St
33c0: 6f 72 65 64 50 72 6f 63 5f 43 72 65 61 74 65 54  oredProc_CreateT
33d0: 61 62 6c 65 73 3c 2f 62 3e 20 69 6e 20 6f 72 64  ables</b> in ord
33e0: 65 72 20 74 6f 20 63 72 65 61 74 65 20 6f 6e 20  er to create on 
33f0: 79 6f 75 72 20 63 75 72 72 65 6e 74 6c 79 20 63  your currently c
3400: 6f 6e 6e 65 63 74 65 64 20 64 61 74 61 62 61 73  onnected databas
3410: 65 20 61 6c 6c 20 3c 62 3e 6d 65 74 61 74 61 62  e all <b>metatab
3420: 6c 65 73 3c 2f 62 3e 20 72 65 71 75 69 72 65 64  les</b> required
3430: 20 74 6f 20 70 65 72 6d 61 6e 65 6e 74 6c 79 20   to permanently 
3440: 72 65 67 69 73 74 65 72 20 53 74 6f 72 65 64 20  register Stored 
3450: 50 72 6f 63 65 64 75 72 65 73 20 61 6e 64 20 53  Procedures and S
3460: 74 6f 72 65 64 20 56 61 72 69 61 62 6c 65 73 2e  tored Variables.
3470: 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65  <br><br>..<table
3480: 20 62 67 63 6f 6c 6f 72 3d 22 23 66 38 66 38 64   bgcolor="#f8f8d
3490: 38 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22  8" cellpadding="
34a0: 36 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22  6" cellspacing="
34b0: 38 22 3e 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 75 3e  8"><tr><td>..<u>
34c0: 4e 6f 74 65 3c 2f 75 3e 3a 20 61 6e 79 20 6e 65  Note</u>: any ne
34d0: 77 20 64 61 74 61 62 61 73 65 20 63 72 65 61 74  w database creat
34e0: 65 64 20 62 79 20 53 70 61 74 69 61 4c 69 74 65  ed by SpatiaLite
34f0: 20 34 2e 35 2e 30 20 28 61 6e 64 20 73 75 62 73   4.5.0 (and subs
3500: 65 71 75 65 6e 74 20 76 65 72 73 69 6f 6e 73 29  equent versions)
3510: 20 77 69 6c 6c 20 61 75 74 6f 6d 61 74 69 63 61   will automatica
3520: 6c 6c 79 20 73 75 70 70 6f 72 74 20 74 68 65 20  lly support the 
3530: 53 74 6f 72 65 64 20 50 72 6f 63 65 64 75 72 65  Stored Procedure
3540: 73 20 6d 65 74 61 74 61 62 6c 65 73 2e 0d 0a 45  s metatables...E
3550: 78 70 6c 69 63 69 74 6c 79 20 63 61 6c 6c 69 6e  xplicitly callin
3560: 67 20 74 68 69 73 20 66 75 6e 63 74 69 6f 6e 20  g this function 
3570: 69 73 20 6d 61 69 6e 6c 79 20 75 73 65 66 75 6c  is mainly useful
3580: 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 72 65 74   in order to ret
3590: 72 6f 66 69 74 20 53 74 6f 72 65 64 20 50 72 6f  rofit Stored Pro
35a0: 63 65 64 75 72 65 73 20 73 75 70 70 6f 72 74 20  cedures support 
35b0: 6f 6e 20 61 6c 72 65 61 64 79 20 65 78 69 73 74  on already exist
35c0: 69 6e 67 20 64 61 74 61 62 61 73 65 73 20 63 72  ing databases cr
35d0: 65 61 74 65 20 62 79 20 70 72 65 76 69 6f 75 73  eate by previous
35e0: 20 76 65 72 73 69 6f 6e 73 2e 0d 0a 43 61 6c 6c   versions...Call
35f0: 69 6e 67 20 3c 62 3e 53 74 6f 72 65 64 50 72 6f  ing <b>StoredPro
3600: 63 5f 43 72 65 61 74 65 54 61 62 6c 65 73 3c 2f  c_CreateTables</
3610: 62 3e 20 6f 6e 20 62 65 68 61 6c 66 20 6f 66 20  b> on behalf of 
3620: 61 20 64 61 74 61 62 61 73 65 20 61 6c 72 65 61  a database alrea
3630: 64 79 20 73 75 70 70 6f 72 74 69 6e 67 20 74 68  dy supporting th
3640: 65 20 53 74 6f 72 65 64 20 50 72 6f 63 65 64 75  e Stored Procedu
3650: 72 65 73 20 6d 65 74 61 74 61 62 6c 65 20 69 73  res metatable is
3660: 20 61 6e 20 68 61 72 6d 6c 65 73 73 20 6f 70 65   an harmless ope
3670: 72 61 74 69 6f 6e 20 73 69 6d 70 6c 79 20 72 65  ration simply re
3680: 74 75 72 6e 69 6e 67 20 3c 62 3e 31 3c 2f 62 3e  turning <b>1</b>
3690: 20 28 66 75 6c 6c 20 73 75 63 63 65 73 73 29 2e   (full success).
36a0: 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61  ..</td></tr></ta
36b0: 62 6c 65 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e  ble>..<verbatim>
36c0: 0d 0a 53 45 4c 45 43 54 20 53 74 6f 72 65 64 50  ..SELECT StoredP
36d0: 72 6f 63 5f 52 65 67 69 73 74 65 72 20 28 20 27  roc_Register ( '
36e0: 73 70 5f 31 27 2c 20 27 61 20 73 61 6d 70 6c 65  sp_1', 'a sample
36f0: 20 53 74 6f 72 65 64 20 50 72 6f 63 65 64 75 72   Stored Procedur
3700: 65 20 66 6f 72 20 74 65 73 74 69 6e 67 27 2c 20  e for testing', 
3710: 53 71 6c 50 72 6f 63 5f 46 72 6f 6d 54 65 78 74  SqlProc_FromText
3720: 28 27 53 45 4c 45 43 54 20 40 63 6f 6c 40 20 46  ('SELECT @col@ F
3730: 52 4f 4d 20 40 74 62 6c 40 3b 27 20 29 29 3b 0d  ROM @tbl@;' ));.
3740: 0a 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72  .-----..1..</ver
3750: 62 61 74 69 6d 3e 0d 0a 79 6f 75 20 63 61 6e 20  batim>..you can 
3760: 75 73 65 20 3c 62 3e 53 74 6f 72 65 64 50 72 6f  use <b>StoredPro
3770: 63 5f 52 65 67 69 73 74 65 72 3c 2f 62 3e 20 69  c_Register</b> i
3780: 6e 20 6f 72 64 65 72 20 74 6f 20 70 65 72 6d 61  n order to perma
3790: 6e 65 6e 74 6c 79 20 72 65 67 69 73 74 65 72 20  nently register 
37a0: 61 20 53 74 6f 72 65 64 20 50 72 6f 63 65 64 75  a Stored Procedu
37b0: 72 65 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d  re...<verbatim>.
37c0: 0a 53 45 4c 45 43 54 20 53 74 6f 72 65 64 50 72  .SELECT StoredPr
37d0: 6f 63 5f 44 65 6c 65 74 65 20 28 20 27 73 70 5f  oc_Delete ( 'sp_
37e0: 31 27 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 31 0d  1' );..-----..1.
37f0: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 79 6f  .</verbatim>..yo
3800: 75 20 63 61 6e 20 75 73 65 20 3c 62 3e 53 74 6f  u can use <b>Sto
3810: 72 65 64 50 72 6f 63 5f 44 65 6c 65 74 65 3c 2f  redProc_Delete</
3820: 62 3e 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 70  b> in order to p
3830: 65 72 6d 61 6e 65 6e 74 6c 79 20 72 65 6d 6f 76  ermanently remov
3840: 65 20 61 20 70 72 65 76 69 6f 75 73 6c 79 20 72  e a previously r
3850: 65 67 69 73 74 65 72 65 64 20 53 74 6f 72 65 64  egistered Stored
3860: 20 50 72 6f 63 65 64 75 72 65 2e 0d 0a 3c 76 65   Procedure...<ve
3870: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20  rbatim>..SELECT 
3880: 53 71 6c 50 72 6f 63 5f 52 61 77 53 51 4c 20 28  SqlProc_RawSQL (
3890: 20 53 74 6f 72 65 64 50 72 6f 63 5f 47 65 74 20   StoredProc_Get 
38a0: 28 20 27 73 70 5f 31 27 20 29 20 29 3b 0d 0a 2d  ( 'sp_1' ) );..-
38b0: 2d 2d 2d 2d 0d 0a 53 45 4c 45 43 54 20 40 63 6f  ----..SELECT @co
38c0: 6c 40 20 46 52 4f 4d 20 40 74 62 6c 40 3b 0d 0a  l@ FROM @tbl@;..
38d0: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 79 6f 75  </verbatim>..you
38e0: 20 63 61 6e 20 75 73 65 20 3c 62 3e 53 74 6f 72   can use <b>Stor
38f0: 65 64 50 72 6f 63 5f 47 65 74 3c 2f 62 3e 20 69  edProc_Get</b> i
3900: 6e 20 6f 72 64 65 72 20 74 6f 20 72 65 74 72 69  n order to retri
3910: 65 76 65 20 74 68 65 20 53 51 4c 20 50 72 6f 63  eve the SQL Proc
3920: 65 64 75 72 65 20 42 4c 4f 42 20 4f 62 6a 65 63  edure BLOB Objec
3930: 74 20 66 72 6f 6d 20 61 20 72 65 67 69 73 74 65  t from a registe
3940: 72 65 64 20 53 74 6f 72 65 64 20 50 72 6f 63 65  red Stored Proce
3950: 64 75 72 65 2e 0d 0a 3c 76 65 72 62 61 74 69 6d  dure...<verbatim
3960: 3e 0d 0a 53 45 4c 45 43 54 20 53 74 6f 72 65 64  >..SELECT Stored
3970: 50 72 6f 63 5f 55 70 64 61 74 65 54 69 74 6c 65  Proc_UpdateTitle
3980: 20 28 20 27 73 70 5f 31 27 2c 20 27 74 68 69 73   ( 'sp_1', 'this
3990: 20 54 69 74 6c 65 20 77 61 73 20 63 68 61 6e 67   Title was chang
39a0: 65 64 27 20 29 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a  ed' ));..-----..
39b0: 31 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  1..</verbatim>..
39c0: 79 6f 75 20 63 61 6e 20 75 73 65 20 3c 62 3e 53  you can use <b>S
39d0: 74 6f 72 65 64 50 72 6f 63 5f 55 70 64 61 74 65  toredProc_Update
39e0: 54 69 74 6c 65 3c 2f 62 3e 20 69 6e 20 6f 72 64  Title</b> in ord
39f0: 65 72 20 74 6f 20 6d 6f 64 69 66 79 20 74 68 65  er to modify the
3a00: 20 54 69 74 6c 65 20 6f 66 20 61 6e 20 61 6c 72   Title of an alr
3a10: 65 61 64 79 20 72 65 67 69 73 74 65 72 65 64 20  eady registered 
3a20: 53 74 6f 72 65 64 20 50 72 6f 63 65 64 75 72 65  Stored Procedure
3a30: 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  ...<verbatim>..S
3a40: 45 4c 45 43 54 20 53 74 6f 72 65 64 50 72 6f 63  ELECT StoredProc
3a50: 5f 55 70 64 61 74 65 53 71 6c 42 6f 64 79 20 28  _UpdateSqlBody (
3a60: 20 27 73 70 5f 31 27 2c 20 53 71 6c 50 72 6f 63   'sp_1', SqlProc
3a70: 5f 46 72 6f 6d 46 69 6c 65 28 27 2f 68 6f 6d 65  _FromFile('/home
3a80: 2f 6a 6f 65 2f 73 71 6c 5f 73 63 72 69 70 74 73  /joe/sql_scripts
3a90: 2f 73 74 6f 72 65 64 5f 70 72 6f 63 5f 74 65 73  /stored_proc_tes
3aa0: 74 5f 76 32 2e 74 78 74 27 20 29 29 3b 0d 0a 2d  t_v2.txt' ));..-
3ab0: 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72 62 61  ----..1..</verba
3ac0: 74 69 6d 3e 0d 0a 79 6f 75 20 63 61 6e 20 75 73  tim>..you can us
3ad0: 65 20 3c 62 3e 53 74 6f 72 65 64 50 72 6f 63 5f  e <b>StoredProc_
3ae0: 55 70 64 61 74 65 53 71 6c 42 6f 64 79 3c 2f 62  UpdateSqlBody</b
3af0: 3e 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 6d 6f  > in order to mo
3b00: 64 69 66 79 20 74 68 65 20 53 71 6c 20 42 6f 64  dify the Sql Bod
3b10: 79 20 6f 66 20 61 6e 20 61 6c 72 65 61 64 79 20  y of an already 
3b20: 72 65 67 69 73 74 65 72 65 64 20 53 74 6f 72 65  registered Store
3b30: 64 20 50 72 6f 63 65 64 75 72 65 20 28 65 2e 67  d Procedure (e.g
3b40: 2e 20 62 65 63 61 75 73 65 20 79 6f 75 27 76 65  . because you've
3b50: 20 64 69 73 63 6f 76 65 72 65 64 20 61 6e 64 20   discovered and 
3b60: 66 69 78 65 64 20 73 6f 6d 65 20 62 75 67 20 61  fixed some bug a
3b70: 66 66 65 63 74 69 6e 67 20 74 68 65 20 70 72 65  ffecting the pre
3b80: 76 69 6f 75 73 20 53 51 4c 20 69 6d 70 6c 65 6d  vious SQL implem
3b90: 65 6e 74 61 74 69 6f 6e 29 2e 3c 76 65 72 62 61  entation).<verba
3ba0: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 74 6f  tim>..SELECT Sto
3bb0: 72 65 64 50 72 6f 63 5f 45 78 65 63 75 74 65 20  redProc_Execute 
3bc0: 28 20 27 73 70 5f 31 27 2c 0d 0a 20 20 20 20 27  ( 'sp_1',..    '
3bd0: 40 63 6f 6c 40 3d 66 69 72 73 74 5f 6e 61 6d 65  @col@=first_name
3be0: 27 2c 0d 0a 20 20 20 20 27 40 74 62 6c 40 3d 70  ',..    '@tbl@=p
3bf0: 68 6f 6e 65 5f 62 6f 6f 6b 27 20 29 3b 0d 0a 2d  hone_book' );..-
3c00: 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72 62 61  ----..1..</verba
3c10: 74 69 6d 3e 0d 0a 61 6e 64 20 66 69 6e 61 6c 6c  tim>..and finall
3c20: 79 20 79 6f 75 20 63 61 6e 20 75 73 65 20 3c 62  y you can use <b
3c30: 3e 53 74 6f 72 65 64 50 72 6f 63 5f 45 78 65 63  >StoredProc_Exec
3c40: 75 74 65 3c 2f 62 3e 20 69 6e 20 6f 72 64 65 72  ute</b> in order
3c50: 20 74 6f 20 64 69 72 65 63 74 6c 79 20 65 78 65   to directly exe
3c60: 63 75 74 65 20 61 20 53 74 6f 72 65 64 20 50 72  cute a Stored Pr
3c70: 6f 63 65 64 75 72 65 20 61 73 20 61 20 73 69 6e  ocedure as a sin
3c80: 67 6c 65 20 6d 6f 6e 6f 6c 69 74 68 69 63 20 75  gle monolithic u
3c90: 6e 69 74 2e 3c 62 72 3e 0d 0a 3c 62 72 3e 3c 62  nit.<br>..<br><b
3ca0: 72 3e 3c 68 72 3e 0d 0a 3c 2f 6c 69 3e 0d 0a 3c  r><hr>..</li>..<
3cb0: 6c 69 3e 0d 0a 3c 68 34 3e 48 61 6e 64 6c 69 6e  li>..<h4>Handlin
3cc0: 67 20 53 51 4c 20 53 74 6f 72 65 64 20 56 61 72  g SQL Stored Var
3cd0: 69 61 62 6c 65 73 3c 2f 68 34 3e 0d 0a 3c 76 65  iables</h4>..<ve
3ce0: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20  rbatim>..SELECT 
3cf0: 53 74 6f 72 65 64 56 61 72 5f 52 65 67 69 73 74  StoredVar_Regist
3d00: 65 72 20 28 20 27 76 61 72 5f 31 27 2c 20 27 61  er ( 'var_1', 'a
3d10: 6e 20 75 6e 69 76 65 72 73 61 6c 6c 79 20 75 73  n universally us
3d20: 65 66 75 6c 20 63 6f 6e 73 74 61 6e 74 27 2c 20  eful constant', 
3d30: 27 40 50 49 40 3d 33 2e 31 34 27 20 29 29 3b 0d  '@PI@=3.14' ));.
3d40: 0a 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72  .-----..1..</ver
3d50: 62 61 74 69 6d 3e 0d 0a 79 6f 75 20 63 61 6e 20  batim>..you can 
3d60: 75 73 65 20 3c 62 3e 53 74 6f 72 65 64 56 61 72  use <b>StoredVar
3d70: 5f 52 65 67 69 73 74 65 72 3c 2f 62 3e 20 69 6e  _Register</b> in
3d80: 20 6f 72 64 65 72 20 74 6f 20 70 65 72 6d 61 6e   order to perman
3d90: 65 6e 74 6c 79 20 72 65 67 69 73 74 65 72 20 61  ently register a
3da0: 20 53 74 6f 72 65 64 20 56 61 72 69 61 62 6c 65   Stored Variable
3db0: 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  ...<verbatim>..S
3dc0: 45 4c 45 43 54 20 53 74 6f 72 65 64 56 61 72 5f  ELECT StoredVar_
3dd0: 44 65 6c 65 74 65 20 28 20 27 76 61 72 5f 31 27  Delete ( 'var_1'
3de0: 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c   );..-----..1..<
3df0: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 79 6f 75 20  /verbatim>..you 
3e00: 63 61 6e 20 75 73 65 20 3c 62 3e 53 74 6f 72 65  can use <b>Store
3e10: 64 56 61 72 5f 44 65 6c 65 74 65 3c 2f 62 3e 20  dVar_Delete</b> 
3e20: 69 6e 20 6f 72 64 65 72 20 74 6f 20 70 65 72 6d  in order to perm
3e30: 61 6e 65 6e 74 6c 79 20 72 65 6d 6f 76 65 20 61  anently remove a
3e40: 20 70 72 65 76 69 6f 75 73 6c 79 20 72 65 67 69   previously regi
3e50: 73 74 65 72 65 64 20 53 74 6f 72 65 64 20 56 61  stered Stored Va
3e60: 72 69 61 62 6c 65 2e 0d 0a 3c 76 65 72 62 61 74  riable...<verbat
3e70: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 74 6f 72  im>..SELECT Stor
3e80: 65 64 56 61 72 5f 47 65 74 20 28 20 27 76 61 72  edVar_Get ( 'var
3e90: 5f 31 27 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d  _1' ) );..-----.
3ea0: 0a 40 50 49 40 3d 33 2e 31 34 0d 0a 3c 2f 76 65  .@PI@=3.14..</ve
3eb0: 72 62 61 74 69 6d 3e 0d 0a 79 6f 75 20 63 61 6e  rbatim>..you can
3ec0: 20 75 73 65 20 3c 62 3e 53 74 6f 72 65 64 56 61   use <b>StoredVa
3ed0: 72 5f 47 65 74 3c 2f 62 3e 20 69 6e 20 6f 72 64  r_Get</b> in ord
3ee0: 65 72 20 74 6f 20 72 65 74 72 69 65 76 65 20 74  er to retrieve t
3ef0: 68 65 20 56 61 72 69 61 62 6c 65 20 77 69 74 68  he Variable with
3f00: 20 56 61 6c 75 65 20 73 74 72 69 6e 67 20 66 72   Value string fr
3f10: 6f 6d 20 61 20 72 65 67 69 73 74 65 72 65 64 20  om a registered 
3f20: 53 74 6f 72 65 64 20 56 61 72 69 61 62 6c 65 2e  Stored Variable.
3f30: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45  ..<verbatim>..SE
3f40: 4c 45 43 54 20 53 74 6f 72 65 64 56 61 72 5f 55  LECT StoredVar_U
3f50: 70 64 61 74 65 54 69 74 6c 65 20 28 20 27 76 61  pdateTitle ( 'va
3f60: 72 5f 31 27 2c 20 27 50 49 20 2d 20 74 68 65 20  r_1', 'PI - the 
3f70: 6d 61 67 69 63 20 6e 75 6d 62 65 72 27 20 29 29  magic number' ))
3f80: 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76  ;..-----..1..</v
3f90: 65 72 62 61 74 69 6d 3e 0d 0a 79 6f 75 20 63 61  erbatim>..you ca
3fa0: 6e 20 75 73 65 20 3c 62 3e 53 74 6f 72 65 64 56  n use <b>StoredV
3fb0: 61 72 5f 55 70 64 61 74 65 54 69 74 6c 65 3c 2f  ar_UpdateTitle</
3fc0: 62 3e 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 6d  b> in order to m
3fd0: 6f 64 69 66 79 20 74 68 65 20 54 69 74 6c 65 20  odify the Title 
3fe0: 6f 66 20 61 6e 20 61 6c 72 65 61 64 79 20 72 65  of an already re
3ff0: 67 69 73 74 65 72 65 64 20 53 74 6f 72 65 64 20  gistered Stored 
4000: 50 72 6f 63 65 64 75 72 65 2e 0d 0a 3c 76 65 72  Procedure...<ver
4010: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53  batim>..SELECT S
4020: 74 6f 72 65 64 56 61 72 5f 55 70 64 61 74 65 56  toredVar_UpdateV
4030: 61 6c 75 65 20 28 20 27 76 61 72 5f 31 27 2c 20  alue ( 'var_1', 
4040: 27 40 50 49 40 3d 33 2e 31 34 31 35 39 32 36 35  '@PI@=3.14159265
4050: 33 35 27 20 29 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a  35' ));..-----..
4060: 31 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  1..</verbatim>..
4070: 61 6e 64 20 66 69 6e 61 6c 6c 79 20 79 6f 75 20  and finally you 
4080: 63 61 6e 20 75 73 65 20 3c 62 3e 53 74 6f 72 65  can use <b>Store
4090: 64 56 61 72 5f 55 70 64 61 74 65 56 61 6c 75 65  dVar_UpdateValue
40a0: 3c 2f 62 3e 20 69 6e 20 6f 72 64 65 72 20 74 6f  </b> in order to
40b0: 20 6d 6f 64 69 66 79 20 74 68 65 20 56 61 72 69   modify the Vari
40c0: 61 62 6c 65 20 77 69 74 68 20 56 61 6c 75 65 20  able with Value 
40d0: 6f 66 20 61 6e 20 61 6c 72 65 61 64 79 20 72 65  of an already re
40e0: 67 69 73 74 65 72 65 64 20 53 74 6f 72 65 64 20  gistered Stored 
40f0: 56 61 72 69 61 62 6c 65 2e 0d 0a 3c 2f 6c 69 3e  Variable...</li>
4100: 0d 0a 3c 2f 6f 6c 3e 0d 0a 3c 62 72 3e 3c 68 72  ..</ol>..<br><hr
4110: 3e 0d 0a 0d 0a 3c 62 72 3e 3c 62 72 3e 0d 0a 3c  >....<br><br>..<
4120: 74 61 62 6c 65 20 77 69 64 74 68 3d 22 31 30 30  table width="100
4130: 25 22 3e 3c 74 72 3e 0d 0a 3c 74 64 20 77 69 64  %"><tr>..<td wid
4140: 74 68 3d 22 33 33 25 22 20 61 6c 69 67 6e 3d 22  th="33%" align="
4150: 6c 65 66 74 22 3e 3c 2f 74 64 3e 0d 0a 3c 74 64  left"></td>..<td
4160: 20 61 6c 69 67 6e 3d 22 63 65 6e 74 65 72 22 3e   align="center">
4170: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f  <a href="https:/
4180: 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74  /www.gaia-gis.it
4190: 2f 66 6f 73 73 69 6c 2f 6c 69 62 73 70 61 74 69  /fossil/libspati
41a0: 61 6c 69 74 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d  alite/wiki?name=
41b0: 34 2e 33 2e 30 2b 64 6f 63 22 3e 62 61 63 6b 20  4.3.0+doc">back 
41c0: 74 6f 20 69 6e 64 65 78 3c 2f 61 3e 3c 2f 74 64  to index</a></td
41d0: 3e 0d 0a 3c 74 64 20 77 69 64 74 68 3d 22 33 33  >..<td width="33
41e0: 25 22 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22  %" align="right"
41f0: 3e 3c 2f 74 64 3e 0d 0a 3c 2f 74 72 3e 3c 2f 74  ></td>..</tr></t
4200: 61 62 6c 65 3e 0a 5a 20 34 64 61 63 35 31 30 33  able>.Z 4dac5103
4210: 66 30 33 66 36 31 39 39 37 66 31 66 35 35 65 32  f03f61997f1f55e2
4220: 39 30 39 62 31 31 33 38 0a                       909b1138.