<commit_before>-----------------------------------------------------------------------
--  ADO Statements -- Database statements
--  Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2017, 2018 <NAME>
--  Written by <NAME> (<EMAIL>)
--
--  Licensed under the Apache License, Version 2.0 (the "License");
--  you may not use this file except in compliance with the License.
--  You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
--  Unless required by applicable law or agreed to in writing, software
--  distributed under the License is distributed on an "AS IS" BASIS,
--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--  See the License for the specific language governing permissions and
--  limitations under the License.
-----------------------------------------------------------------------

with Ada.Strings.Unbounded;
with Ada.Finalization;
with Ada.Calendar;

with ADO.Schemas;
with ADO.Parameters;
with ADO.SQL;
with ADO.Objects;
private with Ada.Unchecked_Conversion;
private with System;
private with Interfaces.C;
private with Interfaces.C.Strings;

--  = Database Statements =
--  The `ADO.Statements` package provides high level operations to construct database
--  statements and execute them.  They allow to represent SQL statements (prepared or not)
--  and provide support to execute them and retreive their result.  The SQL statements are
--  represented by several Ada types depending on their behavior:
--
--  * The `Statement` type represents the base type for all the SQL statements.
--  * The `Query_Statement` type is intended to be used for database query statements
--    and provides additional operations to retrieve results.
--  * The `Update_Statement` type targets the database update statements and it
--    provides specific operations to update fields.  The `Insert_Statement`
--    extends the `Update_Statement` type and is intended for database insertion.
--  * The `Delete_Statement` type is intended to be used to remove elements
--    from the database.
--
--  The database statements are created by using the database session and by providing
--  the SQL or the named query to be used.
--
--  @include ado-parameters.ads
--
--  == Query Statement ==
--  The database query statement is represented by the `Query_Statement` type.
--  The `Create_Statement` operation is provided on the `Session` type
--  and it gets the SQL to execute as parameter.  For example:
--
--    Stmt : ADO.Statements.Query_Statement := Session.Create_Statement
--              ("select * from user where name = :name");
--
--  After the creation of the query statement, the parameters for the SQL query are provided
--  by using either the `Bind_Param` or `Add_Param` procedures as follows:
--
--    Stmt.Bind_Param ("name", name);
--
--  Once all the parameters are defined, the query statement is executed by calling the
--  `Execute` procedure:
--
--    Stmt.Execute;
--
--  Several operations are provided to retrieve the result.  First, the `Has_Elements`
--  function will indicate whether some database rows are available in the result.  It is then
--  possible to retrieve each row and proceed to the next one by calling the `Next`
--  procedure.  The number of rows is also returned by the `Get_Row_Count` function.
--  A simple loop to iterate over the query result looks like:
--
--    while Stmt.Has_Elements loop
--       Id := Stmt.Get_Identifier (1);
--       ...
--       Stmt.Next;
--    end loop;
--
--  @include ado-queries.ads
package ADO.Statements is

   use Ada.Strings.Unbounded;

   Invalid_Statement : exception;

   Invalid_Column    : exception;

   Invalid_Type      : exception;

   --  ---------
   --  SQL statement
   --  ---------
   --  The SQL statement
   --
   type Statement is abstract new ADO.Parameters.Abstract_List with private;
   type Statement_Access is access all Statement'Class;<commit_msg>Add comments on declared exceptions<commit_after>-----------------------------------------------------------------------
--  ADO Statements -- Database statements
--  Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2017, 2018 <NAME>
--  Written by <NAME> (<EMAIL>)
--
--  Licensed under the Apache License, Version 2.0 (the "License");
--  you may not use this file except in compliance with the License.
--  You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
--  Unless required by applicable law or agreed to in writing, software
--  distributed under the License is distributed on an "AS IS" BASIS,
--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--  See the License for the specific language governing permissions and
--  limitations under the License.
-----------------------------------------------------------------------

with Ada.Strings.Unbounded;
with Ada.Finalization;
with Ada.Calendar;

with ADO.Schemas;
with ADO.Parameters;
with ADO.SQL;
with ADO.Objects;
private with Ada.Unchecked_Conversion;
private with System;
private with Interfaces.C;
private with Interfaces.C.Strings;

--  = Database Statements =
--  The `ADO.Statements` package provides high level operations to construct database
--  statements and execute them.  They allow to represent SQL statements (prepared or not)
--  and provide support to execute them and retreive their result.  The SQL statements are
--  represented by several Ada types depending on their behavior:
--
--  * The `Statement` type represents the base type for all the SQL statements.
--  * The `Query_Statement` type is intended to be used for database query statements
--    and provides additional operations to retrieve results.
--  * The `Update_Statement` type targets the database update statements and it
--    provides specific operations to update fields.  The `Insert_Statement`
--    extends the `Update_Statement` type and is intended for database insertion.
--  * The `Delete_Statement` type is intended to be used to remove elements
--    from the database.
--
--  The database statements are created by using the database session and by providing
--  the SQL or the named query to be used.
--
--  @include ado-parameters.ads
--
--  == Query Statement ==
--  The database query statement is represented by the `Query_Statement` type.
--  The `Create_Statement` operation is provided on the `Session` type
--  and it gets the SQL to execute as parameter.  For example:
--
--    Stmt : ADO.Statements.Query_Statement := Session.Create_Statement
--              ("select * from user where name = :name");
--
--  After the creation of the query statement, the parameters for the SQL query are provided
--  by using either the `Bind_Param` or `Add_Param` procedures as follows:
--
--    Stmt.Bind_Param ("name", name);
--
--  Once all the parameters are defined, the query statement is executed by calling the
--  `Execute` procedure:
--
--    Stmt.Execute;
--
--  Several operations are provided to retrieve the result.  First, the `Has_Elements`
--  function will indicate whether some database rows are available in the result.  It is then
--  possible to retrieve each row and proceed to the next one by calling the `Next`
--  procedure.  The number of rows is also returned by the `Get_Row_Count` function.
--  A simple loop to iterate over the query result looks like:
--
--    while Stmt.Has_Elements loop
--       Id := Stmt.Get_Identifier (1);
--       ...
--       Stmt.Next;
--    end loop;
--
--  @include ado-queries.ads
package ADO.Statements is

   use Ada.Strings.Unbounded;

   Invalid_Statement : exception;

   --  Exception raised when a column number is invalid.
   Invalid_Column    : exception;

   --  Exception raised when a value cannot be converted to the target type.
   Invalid_Type      : exception;

   --  ---------
   --  SQL statement
   --  ---------
   --  The SQL statement
   --
   type Statement is abstract new ADO.Parameters.Abstract_List with private;
   type Statement_Access is access all Statement'Class;
{'fraction_non_alphanumeric': 0.12409668577124346, 'fraction_numerical': 0.00922003488661849, 'mean_word_length': 2.666971219735039, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3270340', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2039, 'n_words': 944}