From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Ada DB bindings and APQ
Date: Sun, 12 Dec 2004 18:42:04 +0100
Date: 2004-12-12T18:42:04+01:00 [thread overview]
Message-ID: <1km3c584awura$.y7djkir1ozya$.dlg@40tude.net> (raw)
After that hot "Windows Ada database support" discussion I have looked at
APQ by Warren W. Gay. I do believe that it could be used as a starting
point, because it was developed with generic DB access in mind. Here are
things I consider important for further development of APQ:
1. Dynamic binding to target DB.
1.a. A factory which returns Root_Connection_Type'Class depending on the DB
type parameter. Communication DLL should not be loaded until DB connection
requested. Otherwise, all DBs have to be installed.
1.b. A factory which determines the DB type upon connection and returns an
appropriate Root_Connection_Type'Class. (this might be difficult though)
2. Root_Query_Type should know its connection:
function Get_Connection (Query : Root_Query_Type)
return access Root_Connection_Type'Class; -- Ada 2005?
function Get_Connection (Query : Root_Query_Type)
return access Root_Connection_Ptr; -- Ada 95
3. Anyway, Execute should take only one parameter:
Execute (Q); -- Query knows its connection
4. To add a scratch Query to each connection object and make anything
available for a query for Root_Connection_Type as well.
5. Arguably, connection should maintain list of all queries.
6. At least a rudimentary tables management:
Get_Tables (Query : in out Root_Query_Type);
the existing tables can be then fetched.
function Table_Exists (Query : Root_Query_Type; Table_Name : String)
return Boolean;
Drop_Table (Query : in out Root_Query_Type; Table_Name : String);
7. Close/Open_DB_Trace should be primitives of Root_Connection_Type. Same
for Is_Trace.
8. Generic types support:
function <Type_Name>_DB_Type (Connection : Root_Connection_Type)
return String;
yields the native DB name for the given type. For example:
Prepare (Q, "CREATE TABLE customer_name ");
Append (String_DB_Type (My_Connection));
-- How varying strings are named there?
9. For row identifiers there should be three of them:
- Row_ID_DB_Type should return kind of "INTEGER NOT NULL AUTO_INCREMENT
PRIMARY KEY" for MySQL, "SERIAL" for PostgreSQL etc.
- Row_Ref_DB_Type would return "INTEGER" to reference a row.
- Row_New_ID that would return the literal to be used in INSERT, like
"NewID()", "NULL" etc
10. Unicode support (Wide_String etc)
11. Presently values are placed using Append or Append_Quoted. It is IMO
error prone. Proposal: to add dispatching Value, which will encode values
according to the DB:
Prepare (Q, "INSERT ... VALUES (");
Value (Q, Customer, ","); -- Quote if necessary
Value (Q, Clock, ","); -- Use appropriate time literal
Value (Q, Data, ")");
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next reply other threads:[~2004-12-12 17:42 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-12 17:42 Dmitry A. Kazakov [this message]
2004-12-14 7:25 ` Ada DB bindings and APQ Warren W. Gay VE3WWG
2004-12-14 17:37 ` Dmitry A. Kazakov
2004-12-14 18:29 ` Georg Bauhaus
2004-12-14 19:45 ` Dmitry A. Kazakov
2004-12-14 21:06 ` Georg Bauhaus
2004-12-15 8:19 ` Ole-Hjalmar Kristensen
2004-12-15 17:20 ` Dmitry A. Kazakov
2004-12-16 13:28 ` Georg Bauhaus
2004-12-17 13:23 ` Dmitry A. Kazakov
2004-12-14 23:26 ` Brian May
2004-12-15 17:43 ` Dmitry A. Kazakov
2004-12-15 21:54 ` Brian May
2004-12-15 4:05 ` Warren W. Gay VE3WWG
2004-12-15 18:26 ` Dmitry A. Kazakov
2004-12-16 2:53 ` Warren W. Gay VE3WWG
2004-12-18 16:43 ` Dmitry A. Kazakov
2004-12-18 20:36 ` Warren W. Gay VE3WWG
2004-12-18 22:21 ` Dmitry A. Kazakov
2004-12-19 0:53 ` Warren W. Gay VE3WWG
2004-12-19 12:21 ` Dmitry A. Kazakov
2004-12-20 5:33 ` Warren W. Gay VE3WWG
2004-12-20 20:01 ` Dmitry A. Kazakov
2004-12-20 20:54 ` Warren W. Gay VE3WWG
2004-12-14 22:40 ` Brian May
2004-12-15 3:23 ` Warren W. Gay VE3WWG
2004-12-15 15:01 ` Georg Bauhaus
2004-12-17 4:31 ` Brian May
2004-12-15 10:48 ` Brian May
2004-12-16 1:40 ` Brian May
2004-12-16 3:10 ` Warren W. Gay VE3WWG
2004-12-17 4:55 ` Brian May
2004-12-17 11:13 ` Warren W. Gay VE3WWG
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox