From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ee0dc912649d50d4,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Ada DB bindings and APQ Date: Sun, 12 Dec 2004 18:42:04 +0100 Organization: cbb software GmbH Message-ID: <1km3c584awura$.y7djkir1ozya$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: individual.net vOmAxDFpVAsTeDbDSEAqcw2L+FRQvCLxrBFUvfL6X748V/v9o= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:6903 Date: 2004-12-12T18:42:04+01:00 List-Id: 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 _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