package AdaBase is
   type Trax_ID is mod 2 ** 64;
   subtype Affected_Rows is Trax_ID;
end AdaBase;

Affected_Rows function
AdaBase.Driver.Base.[DB].execute (sql : String)

This executes an SQL statement in a single function call, returning the number of rows affected by the statement.

This function does not return results from a SELECT statement. If results are desired, use the query function to obtain a direct or prepared statement that can be executed instead.

with AdaBase;
with Connect;
with Ada.Text_IO;

procedure Fruit1 is

   package CON renames Connect;
   package TIO renames Ada.Text_IO;

   numrows : AdaBase.Affected_Rows;

   cmd : constant String := "DELETE FROM fruits WHERE color = 'red'";

begin

   CON.connect_database;

   numrows := CON.DR.execute (sql => cmd);

   TIO.Put_Line ("SQL: " & cmd);
   TIO.Put_Line ("Result: Deleted" & numrows'Img & " rows");

   CON.DR.rollback;
   CON.DR.disconnect;

end Fruit1;

Example code: testcases/fruit1/fruit1.adb


SQL: DELETE FROM fruits WHERE color = 'red'
Result: Deleted 5 rows

Output using any driver


[DB] is "MySQL.MySQL_Driver", "PostgreSQL.PostgreSQL_Driver", or "SQLite.SQLite_Driver"

See Also