1with AdaBase;
2with Connect;
3with CommonText;
4with Ada.Text_IO;
5with Ada.Exceptions;
6with Ada.Calendar.Formatting;
7with AdaBase.Results.Sets;
8with AdaBase.Logger.Facility;
9with Interfaces;
10with GNAT.Traceback.Symbolic;
11
12procedure All_Types is
13
14   package CON renames Connect;
15   package TIO renames Ada.Text_IO;
16   package AR  renames AdaBase.Results;
17   package ARS renames AdaBase.Results.Sets;
18   package CT  renames CommonText;
19   package ALF renames AdaBase.Logger.Facility;
20   package CAL renames Ada.Calendar;
21   package CFM renames Ada.Calendar.Formatting;
22   package SYM renames GNAT.Traceback.Symbolic;
23   package EX  renames Ada.Exceptions;
24
25   package Byte_Io is new Ada.Text_Io.Modular_Io (Interfaces.Unsigned_8);
26
27   type halfbyte is mod 2 ** 4;
28
29   stmt_acc : CON.Stmt_Type_access;
30
31   procedure dump_result;
32   procedure run_bind_test (sql_request : String; direct : Boolean);
33   function print_time (timevar : CAL.Time) return String;
34   function print_bits (bitdata : AR.Bits) return String;
35   function halfbyte_to_hex (value : halfbyte) return Character;
36   function convert_chain (chain : AR.Chain) return String;
37   function convert_set (set : AR.Settype) return String;
38   function pad (S : String; Slen : Natural) return String;
39   function pad (S : String; Slen : Natural) return String
40   is
41      field : String (1 .. Slen) := (others => ' ');
42      len   : Natural := S'Length;
43   begin
44      field (1 .. len) := S;
45      return field;
46   end pad;
47
48   function halfbyte_to_hex (value : halfbyte) return Character
49   is
50      zero     : constant Natural := Character'Pos ('0');
51      alpham10 : constant Natural := Character'Pos ('A') - 10;
52   begin
53      case value is
54         when 0 .. 9 => return Character'Val (zero + Natural (value));
55         when others => return Character'Val (alpham10 + Natural (value));
56      end case;
57   end halfbyte_to_hex;
58
59   function convert_chain (chain : AR.Chain) return String
60   is
61      use type AR.NByte1;
62      blocks    : constant Natural := chain'Length;
63      mask_ones : constant AR.NByte1 := 16#0F#;
64      work_4bit : halfbyte;
65      result    : String (1 .. blocks * 3 - 1) := (others => ' ');
66      index     : Natural := 0;
67      fullbyte  : Interfaces.Unsigned_8;
68   begin
69      for x in Positive range 1 .. blocks loop
70         index := index + 1;
71         fullbyte := Interfaces.Unsigned_8 (chain (x));
72         fullbyte := Interfaces.Shift_Right (fullbyte, 4);
73         work_4bit := halfbyte (fullbyte);
74         result (index) := halfbyte_to_hex (work_4bit);
75         index := index + 1;
76         work_4bit := halfbyte (chain (x) and mask_ones);
77         result (index) := halfbyte_to_hex (work_4bit);
78         index := index + 1;
79      end loop;
80      if blocks = 0 then
81         return "(empty)";
82      end if;
83      return result;
84   end convert_chain;
85
86   function print_bits (bitdata : AR.Bits) return String
87   is
88      use type AR.Bit1;
89      result : String (1 .. bitdata'Length) := (others => '0');
90      marker : Natural := result'First;
91   begin
92      for x in bitdata'Range loop
93         if bitdata (x) > 0 then
94            result (marker) := '1';
95         end if;
96         marker := marker + 1;
97      end loop;
98      return result;
99   end print_bits;
100
101   function convert_set (set : AR.Settype) return String
102   is
103      result : CT.Text;
104   begin
105      for x in set'Range loop
106         if not CT.IsBlank (set (x).enumeration) then
107            if x > set'First then
108               CT.SU.Append (result, ",");
109            end if;
110            CT.SU.Append (result, set (x).enumeration);
111         end if;
112      end loop;
113      return CT.USS (result);
114   end convert_set;
115
116   procedure dump_result
117   is
118      row     : ARS.Datarow;
119      numcols : constant Natural := stmt_acc.column_count;
120   begin
121      loop
122         row := stmt_acc.fetch_next;
123         exit when row.data_exhausted;
124         for c in Natural range 1 .. numcols loop
125            TIO.Put (CT.zeropad (c, 2) & ". ");
126            TIO.Put (pad (stmt_acc.column_name (c), 16));
127            TIO.Put (pad (stmt_acc.column_native_type (c)'Img, 15));
128            if row.column (c).is_null then
129               TIO.Put_Line ("<null>");
130            else
131               case stmt_acc.column_native_type (c) is
132                  when AdaBase.ft_chain =>
133                     TIO.Put_Line (convert_chain (row.column (c).as_chain));
134                     when others =>
135                     TIO.Put_Line (row.column (c).as_string);
136               end case;
137            end if;
138         end loop;
139      end loop;
140      TIO.Put_Line ("");
141   end dump_result;
142
143   sql1 : constant String := "SELECT nbyte0, nbyte1, nbyte2, id_nbyte3, " &
144                             "nbyte4, nbyte8, byte1, byte2, byte3, byte4, " &
145                             "byte5, real9, real18, exact_decimal, " &
146                             "bit_type, my_date, my_datetime, my_timestamp, " &
147                             "my_time, my_year, fixed_string, " &
148                             "variable_string, my_tinytext, my_text, " &
149                             "my_mediumtext, my_longtext, " &
150                             "enumtype, settype, " &
151                             "my_binary, my_varbinary, " &
152                             "my_tinyblob, my_mediumblob, " &
153                             "my_blob, my_longblob " &
154                             "FROM all_types WHERE id_nbyte3 = 1";
155   sql2 : constant String := "INSERT INTO all_types VALUES (:id_nbyte3, " &
156                             ":nbyte0, :nbyte1, :nbyte2, :nbyte4, :nbyte8, " &
157                             ":byte1, :byte2, :byte3, :byte4, :byte8, " &
158                             ":real9, :real18, :exact, :bit, :date, " &
159                             ":datetime, :timestamp, :time, :year, :fixed, " &
160                             ":varstring, :tinytext, :text, :medtext, " &
161                             ":longtext, :binary, :varbin, :tinyblob, " &
162                             ":medblob, :blob, :longblob, :enumtype, " &
163                             ":settype)";
164   sql3 : constant String := "INSERT INTO all_types (id_nbyte3, nbyte0, " &
165                             "nbyte1, byte2, byte4, nbyte8, real9, real18, " &
166                             "exact_decimal, my_date, my_timestamp, " &
167                             "my_time, my_year, my_tinytext, enumtype, " &
168                             "settype, my_varbinary, my_blob) VALUES " &
169                             "(?,?, ?,?,?,?,?,?, ?,?,?, ?,?,?,?, ?,?,?)";
170
171   function print_time (timevar : CAL.Time) return String is
172   begin
173      return CFM.Image (timevar);
174   exception
175      when others =>
176         return "<conversion failed>";
177   end print_time;
178
179   procedure run_bind_test (sql_request : String; direct : Boolean)
180   is
181      v_nbyte0 : aliased AR.NByte0;
182      v_nbyte1 : aliased AR.NByte1;
183      v_nbyte2 : aliased AR.NByte2;
184      v_nbyte3 : aliased AR.NByte3;
185      v_nbyte4 : aliased AR.NByte4;
186      v_nbyte8 : aliased AR.NByte8;
187      v_byte1  : aliased AR.Byte1;
188      v_byte2  : aliased AR.Byte2;
189      v_byte3  : aliased AR.Byte3;
190      v_byte4  : aliased AR.Byte4;
191      v_byte8  : aliased AR.Byte8;
192      v_exact  : aliased AR.Real18;
193      v_real9  : aliased AR.Real9;
194      v_real18 : aliased AR.Real18;
195      v_text1  : aliased AR.Textual;
196      v_text2  : aliased AR.Textual;
197      v_text3  : aliased AR.Textual;
198      v_text4  : aliased AR.Textual;
199      v_text5  : aliased AR.Textual;
200      v_text6  : aliased AR.Textual;
201      v_time1  : aliased AR.AC.Time;
202      v_time2  : aliased AR.AC.Time;
203      v_time3  : aliased AR.AC.Time;
204      v_time4  : aliased AR.AC.Time;
205      v_year   : aliased AR.NByte2;
206      v_bit    : aliased AR.Bits  := (0 .. 15 => 0);
207      v_chain1 : aliased AR.Chain := (1 .. 4 => 0);
208      v_chain2 : aliased AR.Chain := (1 .. 6 => 0);
209      v_chain3 : aliased AR.Chain := (1 .. 16 => 0);
210      v_chain4 : aliased AR.Chain := (1 .. 16 => 0);
211      v_chain5 : aliased AR.Chain := (1 .. 16 => 0);
212      v_chain6 : aliased AR.Chain := (1 .. 16 => 0);
213      v_enum   : aliased AR.Enumtype;
214      v_set    : aliased AR.Settype := (1 .. 6 => (AR.PARAM_IS_ENUM));
215
216      function Toggle (direct : Boolean) return CON.Stmt_Type;
217      function Toggle (direct : Boolean) return CON.Stmt_Type is
218      begin
219         if direct then
220            return CON.DR.query (sql_request);
221         else
222            return CON.DR.prepare (sql_request);
223         end if;
224      end Toggle;
225
226      stmt : CON.Stmt_Type := Toggle (direct);
227   begin
228      if not direct then
229         if not stmt.execute then
230            goto done;
231         end if;
232      end if;
233         stmt.bind (1, v_nbyte0'Unchecked_Access);
234         stmt.bind (2, v_nbyte1'Unchecked_Access);
235         stmt.bind (3, v_nbyte2'Unchecked_Access);
236         stmt.bind (4, v_nbyte3'Unchecked_Access);
237         stmt.bind (5, v_nbyte4'Unchecked_Access);
238         stmt.bind (6, v_nbyte8'Unchecked_Access);
239         stmt.bind (7,  v_byte1'Unchecked_Access);
240         stmt.bind (8,  v_byte2'Unchecked_Access);
241         stmt.bind (9,  v_byte3'Unchecked_Access);
242         stmt.bind (10, v_byte4'Unchecked_Access);
243         stmt.bind (11, v_byte8'Unchecked_Access);
244         stmt.bind (12, v_real9'Unchecked_Access);
245         stmt.bind (13, v_real18'Unchecked_Access);
246         stmt.bind (14, v_exact'Unchecked_Access);
247         stmt.bind (15, v_bit'Unchecked_Access);
248         stmt.bind (16, v_time1'Unchecked_Access);
249         stmt.bind (17, v_time2'Unchecked_Access);
250         stmt.bind (18, v_time3'Unchecked_Access);
251         stmt.bind (19, v_time4'Unchecked_Access);
252         stmt.bind (20, v_year'Unchecked_Access);
253         stmt.bind (21, v_text1'Unchecked_Access);
254         stmt.bind (22, v_text2'Unchecked_Access);
255         stmt.bind (23, v_text3'Unchecked_Access);
256         stmt.bind (24, v_text4'Unchecked_Access);
257         stmt.bind (25, v_text5'Unchecked_Access);
258         stmt.bind (26, v_text6'Unchecked_Access);
259         stmt.bind (27, v_enum'Unchecked_Access);
260         stmt.bind (28, v_set'Unchecked_Access);
261         stmt.bind (29, v_chain1'Unchecked_Access);
262         stmt.bind (30, v_chain2'Unchecked_Access);
263         stmt.bind (31, v_chain3'Unchecked_Access);
264         stmt.bind (32, v_chain4'Unchecked_Access);
265         stmt.bind (33, v_chain5'Unchecked_Access);
266         stmt.bind (34, v_chain6'Unchecked_Access);
267         TIO.Put_Line ("Dumping Result from PS/Bound fetch ...");
268         loop
269            exit when not stmt.fetch_bound;
270            TIO.Put_Line (" 1. nbyte0          " & v_nbyte0'Img);
271            TIO.Put_Line (" 2. nbyte1          " & v_nbyte1'Img);
272            TIO.Put_Line (" 3. nbyte2          " & v_nbyte2'Img);
273            TIO.Put_Line (" 4. nbyte3          " & v_nbyte3'Img);
274            TIO.Put_Line (" 5. nbyte4          " & v_nbyte4'Img);
275            TIO.Put_Line (" 6. nbyte8          " & v_nbyte8'Img);
276            TIO.Put_Line (" 7. byte1           " & v_byte1'Img);
277            TIO.Put_Line (" 8. byte2           " & v_byte2'Img);
278            TIO.Put_Line (" 9. byte3           " & v_byte3'Img);
279            TIO.Put_Line ("10. byte4           " & v_byte4'Img);
280            TIO.Put_Line ("11. byte8           " & v_byte8'Img);
281            TIO.Put_Line ("12. real9           " & v_real9'Img);
282            TIO.Put_Line ("13. real18          " & v_real18'Img);
283            TIO.Put_Line ("14. exact           " & v_exact'Img);
284            TIO.Put_Line ("15. bits            " & print_bits (v_bit));
285            TIO.Put_Line ("16. date            " & print_time (v_time1));
286            TIO.Put_Line ("17. datetime        " & print_time (v_time2));
287            TIO.Put_Line ("18. timestamp       " & print_time (v_time3));
288            TIO.Put_Line ("19. time            " & print_time (v_time4));
289            TIO.Put_Line ("20. year            " & v_year'Img);
290            TIO.Put_Line ("21. fixed string    " & CT.USS (v_text1));
291            TIO.Put_Line ("22. variable string " & CT.USS (v_text2));
292            TIO.Put_Line ("23. tinytext        " & CT.USS (v_text3));
293            TIO.Put_Line ("24. text            " & CT.USS (v_text4));
294            TIO.Put_Line ("25. medium text     " & CT.USS (v_text5));
295            TIO.Put_Line ("26. long text       " & CT.USS (v_text6));
296            TIO.Put_Line ("27. enum            " & CT.USS
297                                                   (v_enum.enumeration));
298            TIO.Put_Line ("28. settype         " & convert_set (v_set));
299            TIO.Put_Line ("29. binary          " & convert_chain (v_chain1));
300            TIO.Put_Line ("30. varbinary       " & convert_chain (v_chain2));
301            TIO.Put_Line ("31. tiny blob       " & convert_chain (v_chain3));
302            TIO.Put_Line ("32. medium blob     " & convert_chain (v_chain4));
303            TIO.Put_Line ("33. blob            " & convert_chain (v_chain5));
304            TIO.Put_Line ("34. long blob       " & convert_chain (v_chain6));
305         end loop;
306      <<done>>
307   end run_bind_test;
308
309begin
310
311   CON.DR.command_standard_logger (device => ALF.file, action => ALF.attach);
312
313   CON.connect_database;
314
315   declare
316      stmt : aliased CON.Stmt_Type := CON.DR.query (sql1);
317   begin
318      if stmt.successful then
319         stmt_acc := stmt'Unchecked_Access;
320         TIO.Put_Line ("Dumping Result from direct statement ...");
321         dump_result;
322      end if;
323   end;
324
325   declare
326      stmt : aliased CON.Stmt_Type := CON.DR.prepare (sql1);
327   begin
328      if stmt.execute then
329         stmt_acc := stmt'Unchecked_Access;
330         TIO.Put_Line ("Dumping Result from prepared statement ...");
331         dump_result;
332      else
333         TIO.Put_Line ("statement execution failed");
334      end if;
335   end;
336
337   run_bind_test (sql1, False);
338
339   declare
340      numrows : AdaBase.Affected_Rows;
341   begin
342      numrows := CON.DR.execute ("DELETE FROM all_types WHERE id_nbyte3 > 8");
343      CON.DR.commit;
344   end;
345
346   declare
347      v_nbyte0 : aliased AR.NByte0  := False;
348      v_nbyte1 : aliased AR.NByte1  := 22;
349      v_nbyte2 : aliased AR.NByte2  := 5800;
350      v_nbyte3 : aliased AR.NByte3  := 9;
351      v_nbyte4 : aliased AR.NByte4  := AR.NByte4 (2 ** 20);
352      v_nbyte8 : aliased AR.NByte8  := AR.NByte8 (2 ** 24 + 1);
353      v_byte1  : aliased AR.Byte1   := AR.Byte1 (-2);
354      v_byte2  : aliased AR.Byte2   := AR.Byte2 (-132);
355      v_byte3  : aliased AR.Byte3   := AR.Byte3 (-8000000);
356      v_byte4  : aliased AR.Byte4   := 24;
357      v_byte8  : aliased AR.Byte8   := 128;
358      v_exact  : aliased AR.Real9   := 7.32;
359      v_real9  : aliased AR.Real9   := 999.01234;
360      v_real18 : aliased AR.Real18  := 99999.01234567890123456789;
361      v_text1  : aliased AR.Textual := CT.SUS ("Popeye");
362      v_text2  : aliased AR.Textual := CT.SUS ("Daredevel");
363      v_text3  : aliased AR.Textual := CT.SUS ("The Punisher");
364      v_text4  : aliased AR.Textual := CT.SUS ("Electra");
365      v_text5  : aliased AR.Textual := CT.SUS ("Iron Man");
366      v_text6  : aliased AR.Textual := CT.SUS ("Bruce Banner");
367      v_time1  : aliased AR.AC.Time := CFM.Time_Of (1995, 2, 14);
368      v_time2  : aliased AR.AC.Time := CFM.Time_Of (1998, 3, 17, 6, 7, 8);
369      v_time3  : aliased AR.AC.Time := CFM.Time_Of (2005, 4, 20, 1, 32, 0);
370      v_time4  : aliased AR.AC.Time := CFM.Time_Of (1901, 1, 1, 4, 57, 50);
371      v_year   : aliased AR.NByte2  := 1992;
372      v_bit    : aliased AR.Textual := CT.SUS ("010101111111");
373      v_chain1 : aliased AR.Chain   := (12, 44, 65, 240);
374      v_chain2 : aliased AR.Chain   := (97, 99, 102);
375      v_chain3 : aliased AR.Chain   := (1, 0, 20, 37, 10);
376      v_chain4 : aliased AR.Chain   := (200, 232, 98, 100, 77, 82);
377      v_chain5 : aliased AR.Chain   := (50, 12, 2, 4, 99, 255, 27);
378      v_chain6 : aliased AR.Chain   := (0, 0, 0, 0, 1, 2, 3, 4);
379      v_enum   : aliased AR.Enumtype := (enumeration => CT.SUS ("pink"));
380      v_set    : aliased AR.Settype := ((enumeration => CT.SUS ("red")),
381                                        (enumeration => CT.SUS ("green")));
382      v_set2   : AR.Settype :=         ((enumeration => CT.SUS ("yellow")),
383                                        (enumeration => CT.SUS ("white")),
384                                        (enumeration => CT.SUS ("red")));
385      v_chain7 : AR.Chain := (65, 66, 67, 68);
386      v_chain8 : AR.Chain := (97, 98, 99, 100, 101);
387
388      stmt : CON.Stmt_Type := CON.DR.prepare (sql2);
389   begin
390      stmt.assign ("nbyte0", v_nbyte0'Unchecked_Access);
391      stmt.assign ("nbyte1", v_nbyte1'Unchecked_Access);
392      stmt.assign ("nbyte2", v_nbyte2'Unchecked_Access);
393      stmt.assign ("id_nbyte3", v_nbyte3'Unchecked_Access);
394      stmt.assign ("nbyte4", v_nbyte4'Unchecked_Access);
395      stmt.assign ("nbyte8", v_nbyte8'Unchecked_Access);
396      stmt.assign ("byte1",  v_byte1'Unchecked_Access);
397      stmt.assign ("byte2",  v_byte2'Unchecked_Access);
398      stmt.assign ("byte3",  v_byte3'Unchecked_Access);
399      stmt.assign ("byte4", v_byte4'Unchecked_Access);
400      stmt.assign ("byte8", v_byte8'Unchecked_Access);
401      stmt.assign ("real9", v_real9'Unchecked_Access);
402      stmt.assign ("real18", v_real18'Unchecked_Access);
403      stmt.assign ("exact", v_exact'Unchecked_Access);
404      stmt.assign ("bit", v_bit'Unchecked_Access);
405      stmt.assign ("date", v_time1'Unchecked_Access);
406      stmt.assign ("datetime", v_time2'Unchecked_Access);
407      stmt.assign ("timestamp", v_time3'Unchecked_Access);
408      stmt.assign ("time", v_time4'Unchecked_Access);
409      stmt.assign ("year", v_year'Unchecked_Access);
410      stmt.assign ("fixed", v_text1'Unchecked_Access);
411      stmt.assign ("varstring", v_text2'Unchecked_Access);
412      stmt.assign ("tinytext", v_text3'Unchecked_Access);
413      stmt.assign ("text", v_text4'Unchecked_Access);
414      stmt.assign ("medtext", v_text5'Unchecked_Access);
415      stmt.assign ("longtext", v_text6'Unchecked_Access);
416      stmt.assign ("enumtype", v_enum'Unchecked_Access);
417      stmt.assign ("settype", v_set'Unchecked_Access);
418      stmt.assign ("binary", v_chain1'Unchecked_Access);
419      stmt.assign ("varbin", v_chain2'Unchecked_Access);
420      stmt.assign ("tinyblob", v_chain3'Unchecked_Access);
421      stmt.assign ("medblob", v_chain4'Unchecked_Access);
422      stmt.assign ("blob", v_chain5'Unchecked_Access);
423      stmt.assign ("longblob", v_chain6'Unchecked_Access);
424      TIO.Put_Line ("");
425      if stmt.execute then
426         TIO.Put_Line ("Inserted" & stmt.rows_affected'Img & " row(s)");
427         v_nbyte3 := 11;
428         v_nbyte0 := True;
429         v_text1 := CT.SUS ("Wolverine");
430         v_enum.enumeration := CT.SUS ("blue");
431         if stmt.execute then
432            TIO.Put_Line ("Inserted" & stmt.rows_affected'Img & " row(s)");
433            v_nbyte3 := 15;
434            stmt.assign ("settype", v_set2);
435            stmt.assign ("binary", v_chain7);
436            stmt.assign ("varbin", v_chain8);
437            v_exact := 187.93;
438            if stmt.execute then
439               TIO.Put_Line ("Inserted" & stmt.rows_affected'Img &
440                             " row(s)");
441               CON.DR.commit;
442            else
443               TIO.Put_Line (stmt.last_driver_message);
444               CON.DR.rollback;
445            end if;
446         else
447            TIO.Put_Line (stmt.last_driver_message);
448            CON.DR.rollback;
449         end if;
450      else
451         TIO.Put_Line (stmt.last_driver_message);
452      end if;
453   end;
454
455   declare
456      values : String := "20|1|150|-10|-90000|3200100|87.2341|" &
457        "15555.213792831213|875.44|2014-10-20|2000-03-25 15:15:00|" &
458        "20:18:13|1986|AdaBase is so cool!|green|yellow,black|" &
459        " 0123|456789ABC.,z[]";
460      stmt : CON.Stmt_Type := CON.DR.prepare (sql3);
461   begin
462      values (values'Last - 6) := Character'Val (0);
463      --  This has to be done only once after the prepare command
464      --  Set the type for each parameter (required for at least MySQL)
465      stmt.assign (1,  AR.PARAM_IS_NBYTE_3);
466      stmt.assign (2,  AR.PARAM_IS_BOOLEAN);
467      stmt.assign (3,  AR.PARAM_IS_NBYTE_1);
468      stmt.assign (4,  AR.PARAM_IS_BYTE_2);
469      stmt.assign (5,  AR.PARAM_IS_BYTE_4);
470      stmt.assign (6,  AR.PARAM_IS_NBYTE_8);
471      stmt.assign (7,  AR.PARAM_IS_REAL_9);
472      stmt.assign (8,  AR.PARAM_IS_REAL_18);
473      stmt.assign (9,  AR.PARAM_IS_REAL_18);
474      stmt.assign (10, AR.PARAM_IS_TIMESTAMP);
475      stmt.assign (11, AR.PARAM_IS_TIMESTAMP);
476      stmt.assign (12, AR.PARAM_IS_TIMESTAMP);
477      stmt.assign (13, AR.PARAM_IS_NBYTE_2);
478      stmt.assign (14, AR.PARAM_IS_TEXTUAL);
479      stmt.assign (15, AR.PARAM_IS_ENUM);
480      stmt.assign (16, AR.PARAM_IS_SET);
481      stmt.assign (17, AR.PARAM_IS_CHAIN);
482      stmt.assign (18, AR.PARAM_IS_CHAIN);
483
484      if stmt.execute (values) then
485         TIO.Put_Line ("Inserted" & stmt.rows_affected'Img & " row(s)");
486         CON.DR.commit;
487      else
488         TIO.Put_Line ("statement execution failed");
489         TIO.Put_Line (stmt.last_driver_message);
490      end if;
491   end;
492
493   declare
494      sql20 : String := sql1 (sql1'First .. sql1'Last - 1) & "20";
495      stmt : aliased CON.Stmt_Type := CON.DR.query (sql20);
496   begin
497      if stmt.successful then
498         stmt_acc := stmt'Unchecked_Access;
499         TIO.Put_Line ("Dumping Result from last insert ...");
500         dump_result;
501      end if;
502   end;
503
504   declare
505      sql20 : String := sql1 (sql1'First .. sql1'Last - 1) & "20";
506   begin
507      run_bind_test (sql20, False);
508      TIO.Put_Line ("");
509      run_bind_test (sql20, True);
510   end;
511
512   CON.DR.disconnect;
513
514exception
515   when E : others =>
516      TIO.Put_Line ("");
517      TIO.Put_Line ("exception name: " & EX.Exception_Name (E));
518      TIO.Put_Line ("exception msg : " & EX.Exception_Message (E));
519      TIO.Put_Line ("Traceback:");
520      TIO.Put_Line (SYM.Symbolic_Traceback (E));
521
522end All_Types;
523