1 ------------------------------------------------------------------------------
4 -- Copyright (C) 2006 --
5 -- Pascal Obry - Olivier Ramonat --
7 -- This library is free software; you can redistribute it and/or modify --
8 -- it under the terms of the GNU General Public License as published by --
9 -- the Free Software Foundation; either version 2 of the License, or (at --
10 -- your option) any later version. --
12 -- This library is distributed in the hope that it will be useful, but --
13 -- WITHOUT ANY WARRANTY; without even the implied warranty of --
14 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
15 -- General Public License for more details. --
17 -- You should have received a copy of the GNU General Public License --
18 -- along with this library; if not, write to the Free Software Foundation, --
19 -- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --
20 ------------------------------------------------------------------------------
22 with Ada
.Containers
.Indefinite_Vectors
;
29 -- Raised for all errors reported by the database
31 type Handle
is interface
;
38 User
: in String := "";
39 Password
: in String := "") is abstract;
40 -- Open the database named Name
42 procedure Close
(DB
: in out Handle
) is abstract;
43 -- Close the current database
47 procedure Begin_Transaction
(DB
: in Handle
) is abstract;
48 -- Start a new transaction, do not support embedded transactions
50 procedure Commit
(DB
: in Handle
) is abstract;
51 -- Commit the current transaction
53 procedure Rollback
(DB
: in Handle
) is abstract;
54 -- Rollback the current transaction
58 type Iterator
is interface
;
60 package String_Vectors
is new Containers
.Indefinite_Vectors
61 (Index_Type
=> Positive, Element_Type
=> String);
63 procedure Prepare_Select
65 Iter
: in out Iterator
'Class;
66 SQL
: in String) is abstract;
67 -- Prepare a select statement (SQL must be a select command)
70 (Iter
: in out Iterator
;
71 Result
: out String_Vectors
.Vector
) is abstract;
72 -- Returns the current row and move to the next one
74 function More
(Iter
: in Iterator
) return Boolean is abstract;
75 -- Returns True if there is more data (row) to fetch
77 procedure End_Select
(Iter
: in out Iterator
) is abstract;
78 -- Finalize a select statement
80 procedure Execute
(DB
: in Handle
; SQL
: in String) is abstract;
81 -- Execute SQL request into DB
83 function Last_Insert_Rowid
(DB
: in Handle
) return String is abstract;
84 -- Returns the Id of the last inserted row id