source: trunk/matreshka/source/sql/sql-databases.ads

Last change on this file was 3609, checked in by vadim.godunko, 9 years ago

Change API to pass options to database drivers as a set of name-value
pairs.

Refs #272.

  • Property svn:keywords set to Author Date Revision
File size: 5.2 KB
Line 
1------------------------------------------------------------------------------
2-- --
3-- Matreshka Project --
4-- --
5-- SQL Database Access --
6-- --
7-- Runtime Library Component --
8-- --
9------------------------------------------------------------------------------
10-- --
11-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
12-- All rights reserved. --
13-- --
14-- Redistribution and use in source and binary forms, with or without --
15-- modification, are permitted provided that the following conditions --
16-- are met: --
17-- --
18-- * Redistributions of source code must retain the above copyright --
19-- notice, this list of conditions and the following disclaimer. --
20-- --
21-- * Redistributions in binary form must reproduce the above copyright --
22-- notice, this list of conditions and the following disclaimer in the --
23-- documentation and/or other materials provided with the distribution. --
24-- --
25-- * Neither the name of the Vadim Godunko, IE nor the names of its --
26-- contributors may be used to endorse or promote products derived from --
27-- this software without specific prior written permission. --
28-- --
29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
40-- --
41------------------------------------------------------------------------------
42-- $Revision: 3609 $ $Date: 2012-12-25 10:13:47 +0000 (Tue, 25 Dec 2012) $
43------------------------------------------------------------------------------
44pragma Ada_2012;
45
46private with Ada.Finalization;
47
48with League.Strings;
49private with Matreshka.Internals.SQL_Drivers.Dummy;
50with SQL.Options;
51with SQL.Queries;
52
53package SQL.Databases is
54
55 type SQL_Database is tagged limited private;
56
57 function Create
58 (Driver : League.Strings.Universal_String;
59 Options : SQL.Options.SQL_Options) return SQL_Database;
60
61 procedure Open (Self : in out SQL_Database'Class);
62
63 function Open (Self : in out SQL_Database'Class) return Boolean;
64
65 procedure Close (Self : in out SQL_Database'Class);
66 -- Closes the database connection, freeing any resources acquired, and
67 -- invalidating any existing QSqlQuery objects that are used with the
68 -- database.
69
70 procedure Commit (Self : in out SQL_Database'Class);
71
72 procedure Rollback (Self : in out SQL_Database'Class);
73
74 procedure Transaction (Self : in out SQL_Database'Class);
75
76 function Error_Message
77 (Self : SQL_Database'Class) return League.Strings.Universal_String;
78
79 function Query
80 (Self : in out SQL_Database'Class) return SQL.Queries.SQL_Query;
81 -- Creates SQL_Query object to execute statements in the specified
82 -- database.
83
84 function Query
85 (Self : in out SQL_Database'Class;
86 Query : League.Strings.Universal_String) return SQL.Queries.SQL_Query;
87 -- Creates SQL_Query object to execute statements in the specified
88 -- database and prepare specified statement for execution.
89
90private
91
92 type SQL_Database is new Ada.Finalization.Limited_Controlled with record
93 Data : Matreshka.Internals.SQL_Drivers.Database_Access
94 := Matreshka.Internals.SQL_Drivers.Dummy.Empty_Database'Access;
95 Options : SQL.Options.SQL_Options;
96 end record;
97
98-- overriding procedure Adjust (Self : in out SQL_Database);
99 -- Increments reference counter of shared object.
100
101 overriding procedure Finalize (Self : in out SQL_Database);
102 -- Decrements reference counter of shared object.
103
104end SQL.Databases;
Note: See TracBrowser for help on using the repository browser.