Add support for in-memory database
[gnadelite.git] / src / db.ads
blob85f60a720aebb6c650161dbc9d8e5596cc53e169
1 ------------------------------------------------------------------------------
2 -- GnadeLite --
3 -- --
4 -- Copyright (C) 2006 --
5 -- Pascal Obry - Olivier Ramonat --
6 -- --
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. --
11 -- --
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. --
16 -- --
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;
24 package DB is
26 use Ada;
28 DB_Error : exception;
29 -- Raised for all errors reported by the database
31 type Handle is interface;
33 -- Open / Close
35 procedure Connect
36 (DB : in out Handle;
37 Name : in String;
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
45 -- Transaction
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
56 -- Statement
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
64 (DB : in Handle;
65 Iter : in out Iterator'Class;
66 SQL : in String) is abstract;
67 -- Prepare a select statement (SQL must be a select command)
69 procedure Get_Line
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
86 end DB;