Changes between Version 11 and Version 12 of SQL


Ignore:
Timestamp:
Oct 15, 2011, 6:07:47 PM (9 years ago)
Author:
vadim.godunko
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SQL

    v11 v12  
    1818
    1919with League.Strings;
    20 with League.Values.Floats;
    21 with League.Values.Integers;
     20with League.Holders.Floats;
     21with League.Holders.Integers;
     22--with Matreshka.Internals.SQL_Drivers.OCI.Factory;
     23--with Matreshka.Internals.SQL_Drivers.PostgreSQL.Factory;
     24with Matreshka.Internals.SQL_Drivers.SQLite3.Factory;
    2225with SQL.Databases;
    2326with SQL.Queries;
    2427
    25 with Matreshka.Internals.SQL_Drivers.SQLite3.Factory;
    26 pragma Unreferenced (Matreshka.Internals.SQL_Drivers.SQLite3.Factory);
    27 --  Drivers are linked with application, application must 'with' factory
    28 --  packages to make them available.
    29 
    30 procedure Example is
     28procedure Simple_SQL is
    3129
    3230   function "+"
     
    3432       renames League.Strings.To_Universal_String;
    3533
    36    DB_Type : constant League.Strings.Universal_String := +"SQLITE3";
    37    DB_Name : constant League.Strings.Universal_String := +"test.db";
     34   --  Oracle
     35
     36--   DB_Type : constant League.Strings.Universal_String := +"OCI";
     37--   DB_Name : constant League.Strings.Universal_String := +"scott/tiger@db";
     38
     39   --  PostgreSQL
     40
     41--   DB_Driver  : constant League.Strings.Universal_String := +"POSTGRESQL";
     42--   DB_Options : constant League.Strings.Universal_String := +"";
     43   --  Example: +"user='me' password='my' dbname='db'"
     44
     45   --  SQLite3
     46
     47   DB_Driver  : constant League.Strings.Universal_String := +"SQLITE3";
     48   DB_Options : constant League.Strings.Universal_String := +"test.db";
    3849
    3950   D : aliased SQL.Databases.SQL_Database
    40      := SQL.Databases.Create (DB_Type, DB_Name);
     51     := SQL.Databases.Create (DB_Driver, DB_Options);
    4152
    4253begin
    4354   D.Open;
    4455
    45    --  Create table
    46 
    4756   declare
    48       Q : SQL.Queries.SQL_Query := SQL.Queries.Create (D);
     57      Q : SQL.Queries.SQL_Query := D.Query;
    4958
    5059   begin
     
    5463   end;
    5564
    56    --  Fill data
    57 
    5865   declare
    59       Q : SQL.Queries.SQL_Query := SQL.Queries.Create (D);
     66      Q : SQL.Queries.SQL_Query := D.Query;
    6067
    6168   begin
    6269      Q.Prepare (+"INSERT INTO point (x, y, z) VALUES (:x, :y, :z)");
    63       Q.Bind_Value (+":z", League.Values.Floats.To_Value (4.5));
    64       Q.Bind_Value (+":y", League.Values.To_Value (+"xyz"));
    65       Q.Bind_Value (+":x", League.Values.Integers.To_Value (5));
     70      Q.Bind_Value (+":z", League.Holders.Floats.To_Holder (4.5));
     71      Q.Bind_Value (+":y", League.Holders.To_Holder (+"xyz"));
     72      Q.Bind_Value (+":x", League.Holders.Integers.To_Holder (5));
    6673      Q.Execute;
    6774   end;
    6875
    69    --  Retrieve data from table
    70 
    7176   declare
    72       Q : aliased SQL.Queries.SQL_Query := SQL.Queries.Create (D);
     77      Q : aliased SQL.Queries.SQL_Query := D.Query;
    7378
    7479   begin
     
    7984         Ada.Wide_Wide_Text_IO.Put_Line
    8085          (Integer'Wide_Wide_Image
    81             (League.Values.Integers.Get (Q.Value (1)))
     86            (League.Holders.Integers.Element (Q.Value (1)))
    8287             & ":"
    83              & League.Values.Get (Q.Value (2)).To_Wide_Wide_String
     88             & League.Holders.Element (Q.Value (2)).To_Wide_Wide_String
    8489             & ":"
    8590             & Float'Wide_Wide_Image
    86                 (League.Values.Floats.Get (Q.Value (3))));
     91                (League.Holders.Floats.Element (Q.Value (3))));
    8792      end loop;
    8893   end;
    89 end Example;
     94
     95   D.Close;
     96end Simple_SQL;
    9097}}}