MySQL++

Hex Artifact Content
Login

Hex Artifact Content

Artifact 5f776cd5de0a9e1b79b4431f66c89dabe26f52a205f0580a60703ce771c14a61:


0000: 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  /***************
0010: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0020: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0030: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0040: 2a 2a 2a 2a 2a 2a 2a 2a 0a 20 73 73 71 6c 73 33  ********. ssqls3
0050: 2e 63 70 70 20 2d 20 45 78 61 6d 70 6c 65 20 73  .cpp - Example s
0060: 68 6f 77 69 6e 67 20 68 6f 77 20 74 6f 20 75 70  howing how to up
0070: 64 61 74 65 20 61 6e 20 53 51 4c 20 72 6f 77 20  date an SQL row 
0080: 75 73 69 6e 67 20 74 68 65 0a 09 53 70 65 63 69  using the..Speci
0090: 61 6c 69 7a 65 64 20 53 51 4c 20 53 74 72 75 63  alized SQL Struc
00a0: 74 75 72 65 73 20 66 65 61 74 75 72 65 20 6f 66  tures feature of
00b0: 20 4d 79 53 51 4c 2b 2b 2e 0a 0a 20 43 6f 70 79   MySQL++... Copy
00c0: 72 69 67 68 74 20 28 63 29 20 31 39 39 38 20 62  right (c) 1998 b
00d0: 79 20 4b 65 76 69 6e 20 41 74 6b 69 6e 73 6f 6e  y Kevin Atkinson
00e0: 2c 20 28 63 29 20 31 39 39 39 2d 32 30 30 31 20  , (c) 1999-2001 
00f0: 62 79 20 4d 79 53 51 4c 20 41 42 2c 20 61 6e 64  by MySQL AB, and
0100: 0a 20 28 63 29 20 32 30 30 34 2d 32 30 30 39 20  . (c) 2004-2009 
0110: 62 79 20 45 64 75 63 61 74 69 6f 6e 61 6c 20 54  by Educational T
0120: 65 63 68 6e 6f 6c 6f 67 79 20 52 65 73 6f 75 72  echnology Resour
0130: 63 65 73 2c 20 49 6e 63 2e 20 20 4f 74 68 65 72  ces, Inc.  Other
0140: 73 20 6d 61 79 0a 20 61 6c 73 6f 20 68 6f 6c 64  s may. also hold
0150: 20 63 6f 70 79 72 69 67 68 74 73 20 6f 6e 20 63   copyrights on c
0160: 6f 64 65 20 69 6e 20 74 68 69 73 20 66 69 6c 65  ode in this file
0170: 2e 20 20 53 65 65 20 74 68 65 20 43 52 45 44 49  .  See the CREDI
0180: 54 53 2e 74 78 74 20 66 69 6c 65 0a 20 69 6e 20  TS.txt file. in 
0190: 74 68 65 20 74 6f 70 20 64 69 72 65 63 74 6f 72  the top director
01a0: 79 20 6f 66 20 74 68 65 20 64 69 73 74 72 69 62  y of the distrib
01b0: 75 74 69 6f 6e 20 66 6f 72 20 64 65 74 61 69 6c  ution for detail
01c0: 73 2e 0a 0a 20 54 68 69 73 20 66 69 6c 65 20 69  s... This file i
01d0: 73 20 70 61 72 74 20 6f 66 20 4d 79 53 51 4c 2b  s part of MySQL+
01e0: 2b 2e 0a 0a 20 4d 79 53 51 4c 2b 2b 20 69 73 20  +... MySQL++ is 
01f0: 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79  free software; y
0200: 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62  ou can redistrib
0210: 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 20 6d 6f  ute it and/or mo
0220: 64 69 66 79 20 69 74 0a 20 75 6e 64 65 72 20 74  dify it. under t
0230: 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65 20  he terms of the 
0240: 47 4e 55 20 4c 65 73 73 65 72 20 47 65 6e 65 72  GNU Lesser Gener
0250: 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73  al Public Licens
0260: 65 20 61 73 20 70 75 62 6c 69 73 68 65 64 0a 20  e as published. 
0270: 62 79 20 74 68 65 20 46 72 65 65 20 53 6f 66 74  by the Free Soft
0280: 77 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 3b  ware Foundation;
0290: 20 65 69 74 68 65 72 20 76 65 72 73 69 6f 6e 20   either version 
02a0: 32 2e 31 20 6f 66 20 74 68 65 20 4c 69 63 65 6e  2.1 of the Licen
02b0: 73 65 2c 20 6f 72 0a 20 28 61 74 20 79 6f 75 72  se, or. (at your
02c0: 20 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 74   option) any lat
02d0: 65 72 20 76 65 72 73 69 6f 6e 2e 0a 0a 20 4d 79  er version... My
02e0: 53 51 4c 2b 2b 20 69 73 20 64 69 73 74 72 69 62  SQL++ is distrib
02f0: 75 74 65 64 20 69 6e 20 74 68 65 20 68 6f 70 65  uted in the hope
0300: 20 74 68 61 74 20 69 74 20 77 69 6c 6c 20 62 65   that it will be
0310: 20 75 73 65 66 75 6c 2c 20 62 75 74 20 57 49 54   useful, but WIT
0320: 48 4f 55 54 0a 20 41 4e 59 20 57 41 52 52 41 4e  HOUT. ANY WARRAN
0330: 54 59 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e  TY; without even
0340: 20 74 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72   the implied war
0350: 72 61 6e 74 79 20 6f 66 20 4d 45 52 43 48 41 4e  ranty of MERCHAN
0360: 54 41 42 49 4c 49 54 59 20 6f 72 0a 20 46 49 54  TABILITY or. FIT
0370: 4e 45 53 53 20 46 4f 52 20 41 20 50 41 52 54 49  NESS FOR A PARTI
0380: 43 55 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 20  CULAR PURPOSE.  
0390: 53 65 65 20 74 68 65 20 47 4e 55 20 4c 65 73 73  See the GNU Less
03a0: 65 72 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69  er General Publi
03b0: 63 0a 20 4c 69 63 65 6e 73 65 20 66 6f 72 20 6d  c. License for m
03c0: 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a 0a 20 59  ore details... Y
03d0: 6f 75 20 73 68 6f 75 6c 64 20 68 61 76 65 20 72  ou should have r
03e0: 65 63 65 69 76 65 64 20 61 20 63 6f 70 79 20 6f  eceived a copy o
03f0: 66 20 74 68 65 20 47 4e 55 20 4c 65 73 73 65 72  f the GNU Lesser
0400: 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 0a   General Public.
0410: 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e 67 20 77   License along w
0420: 69 74 68 20 4d 79 53 51 4c 2b 2b 3b 20 69 66 20  ith MySQL++; if 
0430: 6e 6f 74 2c 20 77 72 69 74 65 20 74 6f 20 74 68  not, write to th
0440: 65 20 46 72 65 65 20 53 6f 66 74 77 61 72 65 0a  e Free Software.
0450: 20 46 6f 75 6e 64 61 74 69 6f 6e 2c 20 49 6e 63   Foundation, Inc
0460: 2e 2c 20 35 31 20 46 72 61 6e 6b 6c 69 6e 20 53  ., 51 Franklin S
0470: 74 2c 20 46 69 66 74 68 20 46 6c 6f 6f 72 2c 20  t, Fifth Floor, 
0480: 42 6f 73 74 6f 6e 2c 20 4d 41 20 30 32 31 31 30  Boston, MA 02110
0490: 2d 31 33 30 31 0a 20 55 53 41 0a 2a 2a 2a 2a 2a  -1301. USA.*****
04a0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
04b0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
04c0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
04d0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
04e0: 2a 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 22 63  **/..#include "c
04f0: 6d 64 6c 69 6e 65 2e 68 22 0a 23 69 6e 63 6c 75  mdline.h".#inclu
0500: 64 65 20 22 70 72 69 6e 74 64 61 74 61 2e 68 22  de "printdata.h"
0510: 0a 23 69 6e 63 6c 75 64 65 20 22 73 74 6f 63 6b  .#include "stock
0520: 2e 68 22 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 69  .h"..#include <i
0530: 6f 73 74 72 65 61 6d 3e 0a 0a 75 73 69 6e 67 20  ostream>..using 
0540: 6e 61 6d 65 73 70 61 63 65 20 73 74 64 3b 0a 0a  namespace std;..
0550: 69 6e 74 0a 6d 61 69 6e 28 69 6e 74 20 61 72 67  int.main(int arg
0560: 63 2c 20 63 68 61 72 20 2a 61 72 67 76 5b 5d 29  c, char *argv[])
0570: 0a 7b 0a 09 2f 2f 20 47 65 74 20 64 61 74 61 62  .{..// Get datab
0580: 61 73 65 20 61 63 63 65 73 73 20 70 61 72 61 6d  ase access param
0590: 65 74 65 72 73 20 66 72 6f 6d 20 63 6f 6d 6d 61  eters from comma
05a0: 6e 64 20 6c 69 6e 65 0a 09 6d 79 73 71 6c 70 70  nd line..mysqlpp
05b0: 3a 3a 65 78 61 6d 70 6c 65 73 3a 3a 43 6f 6d 6d  ::examples::Comm
05c0: 61 6e 64 4c 69 6e 65 20 63 6d 64 6c 69 6e 65 28  andLine cmdline(
05d0: 61 72 67 63 2c 20 61 72 67 76 29 3b 0a 09 69 66  argc, argv);..if
05e0: 20 28 21 63 6d 64 6c 69 6e 65 29 20 7b 0a 09 09   (!cmdline) {...
05f0: 72 65 74 75 72 6e 20 31 3b 0a 09 7d 0a 0a 09 74  return 1;..}...t
0600: 72 79 20 7b 0a 09 09 2f 2f 20 45 73 74 61 62 6c  ry {...// Establ
0610: 69 73 68 20 74 68 65 20 63 6f 6e 6e 65 63 74 69  ish the connecti
0620: 6f 6e 20 74 6f 20 74 68 65 20 64 61 74 61 62 61  on to the databa
0630: 73 65 20 73 65 72 76 65 72 2e 0a 09 09 6d 79 73  se server....mys
0640: 71 6c 70 70 3a 3a 43 6f 6e 6e 65 63 74 69 6f 6e  qlpp::Connection
0650: 20 63 6f 6e 28 6d 79 73 71 6c 70 70 3a 3a 65 78   con(mysqlpp::ex
0660: 61 6d 70 6c 65 73 3a 3a 64 62 5f 6e 61 6d 65 2c  amples::db_name,
0670: 0a 09 09 09 09 63 6d 64 6c 69 6e 65 2e 73 65 72  .....cmdline.ser
0680: 76 65 72 28 29 2c 20 63 6d 64 6c 69 6e 65 2e 75  ver(), cmdline.u
0690: 73 65 72 28 29 2c 20 63 6d 64 6c 69 6e 65 2e 70  ser(), cmdline.p
06a0: 61 73 73 28 29 29 3b 0a 0a 09 09 2f 2f 20 42 75  ass());....// Bu
06b0: 69 6c 64 20 61 20 71 75 65 72 79 20 74 6f 20 72  ild a query to r
06c0: 65 74 72 69 65 76 65 20 74 68 65 20 73 74 6f 63  etrieve the stoc
06d0: 6b 20 69 74 65 6d 20 74 68 61 74 20 68 61 73 20  k item that has 
06e0: 55 6e 69 63 6f 64 65 0a 09 09 2f 2f 20 63 68 61  Unicode...// cha
06f0: 72 61 63 74 65 72 73 20 65 6e 63 6f 64 65 64 20  racters encoded 
0700: 69 6e 20 55 54 46 2d 38 20 66 6f 72 6d 2e 0a 09  in UTF-8 form...
0710: 09 6d 79 73 71 6c 70 70 3a 3a 51 75 65 72 79 20  .mysqlpp::Query 
0720: 71 75 65 72 79 20 3d 20 63 6f 6e 2e 71 75 65 72  query = con.quer
0730: 79 28 22 73 65 6c 65 63 74 20 2a 20 66 72 6f 6d  y("select * from
0740: 20 73 74 6f 63 6b 20 22 29 3b 0a 09 09 71 75 65   stock ");...que
0750: 72 79 20 3c 3c 20 22 77 68 65 72 65 20 69 74 65  ry << "where ite
0760: 6d 20 3d 20 22 20 3c 3c 20 6d 79 73 71 6c 70 70  m = " << mysqlpp
0770: 3a 3a 71 75 6f 74 65 20 3c 3c 20 22 4e c3 bc 72  ::quote << "Nür
0780: 6e 62 65 72 67 65 72 20 42 72 61 74 73 22 3b 0a  nberger Brats";.
0790: 0a 09 09 2f 2f 20 52 65 74 72 69 65 76 65 20 74  ...// Retrieve t
07a0: 68 65 20 72 6f 77 2c 20 74 68 72 6f 77 69 6e 67  he row, throwing
07b0: 20 61 6e 20 65 78 63 65 70 74 69 6f 6e 20 69 66   an exception if
07c0: 20 69 74 20 66 61 69 6c 73 2e 0a 09 09 6d 79 73   it fails....mys
07d0: 71 6c 70 70 3a 3a 53 74 6f 72 65 51 75 65 72 79  qlpp::StoreQuery
07e0: 52 65 73 75 6c 74 20 72 65 73 20 3d 20 71 75 65  Result res = que
07f0: 72 79 2e 73 74 6f 72 65 28 29 3b 0a 09 09 69 66  ry.store();...if
0800: 20 28 72 65 73 2e 65 6d 70 74 79 28 29 29 20 7b   (res.empty()) {
0810: 0a 09 09 09 74 68 72 6f 77 20 6d 79 73 71 6c 70  ....throw mysqlp
0820: 70 3a 3a 42 61 64 51 75 65 72 79 28 22 55 54 46  p::BadQuery("UTF
0830: 2d 38 20 62 72 61 74 77 75 72 73 74 20 69 74 65  -8 bratwurst ite
0840: 6d 20 6e 6f 74 20 66 6f 75 6e 64 20 69 6e 20 22  m not found in "
0850: 0a 09 09 09 09 09 22 74 61 62 6c 65 2c 20 72 75  ......"table, ru
0860: 6e 20 72 65 73 65 74 64 62 22 29 3b 0a 09 09 7d  n resetdb");...}
0870: 0a 0a 09 09 2f 2f 20 42 65 63 61 75 73 65 20 74  ....// Because t
0880: 68 65 72 65 20 73 68 6f 75 6c 64 20 6f 6e 6c 79  here should only
0890: 20 62 65 20 6f 6e 65 20 72 6f 77 20 69 6e 20 74   be one row in t
08a0: 68 65 20 72 65 73 75 6c 74 20 73 65 74 2c 0a 09  he result set,..
08b0: 09 2f 2f 20 74 68 65 72 65 27 73 20 6e 6f 20 70  .// there's no p
08c0: 6f 69 6e 74 20 69 6e 20 73 74 6f 72 69 6e 67 20  oint in storing 
08d0: 74 68 65 20 72 65 73 75 6c 74 20 69 6e 20 61 6e  the result in an
08e0: 20 53 54 4c 20 63 6f 6e 74 61 69 6e 65 72 2e 0a   STL container..
08f0: 09 09 2f 2f 20 57 65 20 63 61 6e 20 73 74 6f 72  ..// We can stor
0900: 65 20 74 68 65 20 66 69 72 73 74 20 72 6f 77 20  e the first row 
0910: 64 69 72 65 63 74 6c 79 20 69 6e 74 6f 20 61 20  directly into a 
0920: 73 74 6f 63 6b 20 73 74 72 75 63 74 75 72 65 0a  stock structure.
0930: 09 09 2f 2f 20 62 65 63 61 75 73 65 20 6f 6e 65  ..// because one
0940: 20 6f 66 20 61 6e 20 53 53 51 4c 53 27 73 20 63   of an SSQLS's c
0950: 6f 6e 73 74 72 75 63 74 6f 72 73 20 74 61 6b 65  onstructors take
0960: 73 20 61 20 52 6f 77 20 6f 62 6a 65 63 74 2e 0a  s a Row object..
0970: 09 09 73 74 6f 63 6b 20 72 6f 77 20 3d 20 72 65  ..stock row = re
0980: 73 5b 30 5d 3b 0a 0a 09 09 2f 2f 20 43 72 65 61  s[0];....// Crea
0990: 74 65 20 61 20 63 6f 70 79 20 73 6f 20 74 68 61  te a copy so tha
09a0: 74 20 74 68 65 20 72 65 70 6c 61 63 65 20 71 75  t the replace qu
09b0: 65 72 79 20 6b 6e 6f 77 73 20 77 68 61 74 20 74  ery knows what t
09c0: 68 65 0a 09 09 2f 2f 20 6f 72 69 67 69 6e 61 6c  he...// original
09d0: 20 76 61 6c 75 65 73 20 61 72 65 2e 0a 09 09 73   values are....s
09e0: 74 6f 63 6b 20 6f 72 69 67 5f 72 6f 77 20 3d 20  tock orig_row = 
09f0: 72 6f 77 3b 0a 0a 09 09 2f 2f 20 43 68 61 6e 67  row;....// Chang
0a00: 65 20 74 68 65 20 73 74 6f 63 6b 20 6f 62 6a 65  e the stock obje
0a10: 63 74 27 73 20 69 74 65 6d 20 74 6f 20 75 73 65  ct's item to use
0a20: 20 6f 6e 6c 79 20 37 2d 62 69 74 20 41 53 43 49   only 7-bit ASCI
0a30: 49 2c 20 61 6e 64 0a 09 09 2f 2f 20 74 6f 20 64  I, and...// to d
0a40: 65 6c 69 62 65 72 61 74 65 6c 79 20 62 65 20 77  eliberately be w
0a50: 69 64 65 72 20 74 68 61 6e 20 6e 6f 72 6d 61 6c  ider than normal
0a60: 20 63 6f 6c 75 6d 6e 20 77 69 64 74 68 73 20 70   column widths p
0a70: 72 69 6e 74 65 64 0a 09 09 2f 2f 20 62 79 20 70  rinted...// by p
0a80: 72 69 6e 74 5f 73 74 6f 63 6b 5f 74 61 62 6c 65  rint_stock_table
0a90: 28 29 2e 0a 09 09 72 6f 77 2e 69 74 65 6d 20 3d  ()....row.item =
0aa0: 20 22 4e 75 65 72 65 6e 62 65 72 67 65 72 20 42   "Nuerenberger B
0ab0: 72 61 74 77 75 72 73 74 22 3b 0a 0a 09 09 2f 2f  ratwurst";....//
0ac0: 20 46 6f 72 6d 20 74 68 65 20 71 75 65 72 79 20   Form the query 
0ad0: 74 6f 20 72 65 70 6c 61 63 65 20 74 68 65 20 72  to replace the r
0ae0: 6f 77 20 69 6e 20 74 68 65 20 73 74 6f 63 6b 20  ow in the stock 
0af0: 74 61 62 6c 65 2e 0a 09 09 71 75 65 72 79 2e 75  table....query.u
0b00: 70 64 61 74 65 28 6f 72 69 67 5f 72 6f 77 2c 20  pdate(orig_row, 
0b10: 72 6f 77 29 3b 0a 0a 09 09 2f 2f 20 53 68 6f 77  row);....// Show
0b20: 20 74 68 65 20 71 75 65 72 79 20 61 62 6f 75 74   the query about
0b30: 20 74 6f 20 62 65 20 65 78 65 63 75 74 65 64 2e   to be executed.
0b40: 0a 09 09 63 6f 75 74 20 3c 3c 20 22 51 75 65 72  ...cout << "Quer
0b50: 79 3a 20 22 20 3c 3c 20 71 75 65 72 79 20 3c 3c  y: " << query <<
0b60: 20 65 6e 64 6c 3b 0a 0a 09 09 2f 2f 20 52 75 6e   endl;....// Run
0b70: 20 74 68 65 20 71 75 65 72 79 20 77 69 74 68 20   the query with 
0b80: 65 78 65 63 75 74 65 28 29 2c 20 73 69 6e 63 65  execute(), since
0b90: 20 55 50 44 41 54 45 20 64 6f 65 73 6e 27 74 20   UPDATE doesn't 
0ba0: 72 65 74 75 72 6e 20 61 0a 09 09 2f 2f 20 72 65  return a...// re
0bb0: 73 75 6c 74 20 73 65 74 2e 0a 09 09 71 75 65 72  sult set....quer
0bc0: 79 2e 65 78 65 63 75 74 65 28 29 3b 0a 0a 09 09  y.execute();....
0bd0: 2f 2f 20 52 65 74 72 69 65 76 65 20 61 6e 64 20  // Retrieve and 
0be0: 70 72 69 6e 74 20 6f 75 74 20 74 68 65 20 6e 65  print out the ne
0bf0: 77 20 74 61 62 6c 65 20 63 6f 6e 74 65 6e 74 73  w table contents
0c00: 2e 0a 09 09 70 72 69 6e 74 5f 73 74 6f 63 6b 5f  ....print_stock_
0c10: 74 61 62 6c 65 28 71 75 65 72 79 29 3b 0a 09 7d  table(query);..}
0c20: 0a 09 63 61 74 63 68 20 28 63 6f 6e 73 74 20 6d  ..catch (const m
0c30: 79 73 71 6c 70 70 3a 3a 42 61 64 51 75 65 72 79  ysqlpp::BadQuery
0c40: 26 20 65 72 29 20 7b 0a 09 09 2f 2f 20 48 61 6e  & er) {...// Han
0c50: 64 6c 65 20 61 6e 79 20 71 75 65 72 79 20 65 72  dle any query er
0c60: 72 6f 72 73 0a 09 09 63 65 72 72 20 3c 3c 20 22  rors...cerr << "
0c70: 51 75 65 72 79 20 65 72 72 6f 72 3a 20 22 20 3c  Query error: " <
0c80: 3c 20 65 72 2e 77 68 61 74 28 29 20 3c 3c 20 65  < er.what() << e
0c90: 6e 64 6c 3b 0a 09 09 72 65 74 75 72 6e 20 2d 31  ndl;...return -1
0ca0: 3b 0a 09 7d 0a 09 63 61 74 63 68 20 28 63 6f 6e  ;..}..catch (con
0cb0: 73 74 20 6d 79 73 71 6c 70 70 3a 3a 42 61 64 43  st mysqlpp::BadC
0cc0: 6f 6e 76 65 72 73 69 6f 6e 26 20 65 72 29 20 7b  onversion& er) {
0cd0: 0a 09 09 2f 2f 20 48 61 6e 64 6c 65 20 62 61 64  ...// Handle bad
0ce0: 20 63 6f 6e 76 65 72 73 69 6f 6e 73 0a 09 09 63   conversions...c
0cf0: 65 72 72 20 3c 3c 20 22 43 6f 6e 76 65 72 73 69  err << "Conversi
0d00: 6f 6e 20 65 72 72 6f 72 3a 20 22 20 3c 3c 20 65  on error: " << e
0d10: 72 2e 77 68 61 74 28 29 20 3c 3c 20 65 6e 64 6c  r.what() << endl
0d20: 20 3c 3c 0a 09 09 09 09 22 5c 74 72 65 74 72 69   <<....."\tretri
0d30: 65 76 65 64 20 64 61 74 61 20 73 69 7a 65 3a 20  eved data size: 
0d40: 22 20 3c 3c 20 65 72 2e 72 65 74 72 69 65 76 65  " << er.retrieve
0d50: 64 20 3c 3c 0a 09 09 09 09 22 2c 20 61 63 74 75  d <<.....", actu
0d60: 61 6c 20 73 69 7a 65 3a 20 22 20 3c 3c 20 65 72  al size: " << er
0d70: 2e 61 63 74 75 61 6c 5f 73 69 7a 65 20 3c 3c 20  .actual_size << 
0d80: 65 6e 64 6c 3b 0a 09 09 72 65 74 75 72 6e 20 2d  endl;...return -
0d90: 31 3b 0a 09 7d 0a 09 63 61 74 63 68 20 28 63 6f  1;..}..catch (co
0da0: 6e 73 74 20 6d 79 73 71 6c 70 70 3a 3a 45 78 63  nst mysqlpp::Exc
0db0: 65 70 74 69 6f 6e 26 20 65 72 29 20 7b 0a 09 09  eption& er) {...
0dc0: 2f 2f 20 43 61 74 63 68 2d 61 6c 6c 20 66 6f 72  // Catch-all for
0dd0: 20 61 6e 79 20 6f 74 68 65 72 20 4d 79 53 51 4c   any other MySQL
0de0: 2b 2b 20 65 78 63 65 70 74 69 6f 6e 73 0a 09 09  ++ exceptions...
0df0: 63 65 72 72 20 3c 3c 20 22 45 72 72 6f 72 3a 20  cerr << "Error: 
0e00: 22 20 3c 3c 20 65 72 2e 77 68 61 74 28 29 20 3c  " << er.what() <
0e10: 3c 20 65 6e 64 6c 3b 0a 09 09 72 65 74 75 72 6e  < endl;...return
0e20: 20 2d 31 3b 0a 09 7d 0a 0a 09 72 65 74 75 72 6e   -1;..}...return
0e30: 20 30 3b 0a 7d 0a                                 0;.}.