text stringlengths 0 234 |
|---|
Function Body: Ada.Unchecked_Deallocation (Object => Counter_Map_Array, |
Name => Counter_Map_Array_Access); |
Day : Ada.Calendar.Time; |
Counters : Counter_Map_Array_Access; |
begin |
Plugin.Counters.Steal_Counters (Counters, Day); |
if Counters = null then |
return; |
end if; |
declare |
DB : ADO.Sessions.Master_Session := Plugin.Get_Master_Session; |
Date : constant Ada.Calendar.Time := Util.Dates.Get_Day_Start (Day); |
Def_Id : Natural; |
begin |
DB.Begin_Transaction; |
for I in Counters'Range loop |
if not Counters (I).Is_Empty then |
declare |
Counter : constant Counter_Def := Counter_Arrays.Get_Element (I).all; |
begin |
Plugin.Counters.Get_Definition (DB, I, Def_Id); |
Flush (DB, Counter, Def_Id, Counters (I), Date); |
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation |
Function Body: (Counter_Impl, Counter_Impl_Ptr); |
pragma Warnings (Off, "*redundant conversion*"); |
Ptr : Counter_Impl_Ptr := Counter_Impl (Object.all)'Access; |
pragma Warnings (On, "*redundant conversion*"); |
begin |
Unchecked_Free (Ptr); |
end Destroy; |
procedure Find (Object : in out Counter_Impl; |
Session : in out ADO.Sessions.Session'Class; |
Query : in ADO.SQL.Query'Class; |
Found : out Boolean) is |
Stmt : ADO.Statements.Query_Statement |
:= Session.Create_Statement (Query, COUNTER_DEF'Access); |
begin |
Stmt.Execute; |
if Stmt.Has_Elements then |
Object.Load (Stmt, Session); |
Stmt.Next; |
Found := not Stmt.Has_Elements; |
else |
Found := False; |
end if; |
end Find; |
overriding |
procedure Load (Object : in out Counter_Impl; |
Session : in out ADO.Sessions.Session'Class) is |
Found : Boolean; |
Query : ADO.SQL.Query; |
Id : constant ADO.Identifier := Object.Get_Key_Value; |
begin |
Query.Bind_Param (Position => 1, Value => Id); |
Query.Set_Filter ("definition_id = ?"); |
Object.Find (Session, Query, Found); |
if not Found then |
raise ADO.Objects.NOT_FOUND; |
end if; |
end Load; |
procedure Save (Object : in out Counter_Impl; |
Session : in out ADO.Sessions.Master_Session'Class) is |
Stmt : ADO.Statements.Update_Statement |
:= Session.Create_Statement (COUNTER_DEF'Access); |
begin |
if Object.Is_Modified (1) then |
Stmt.Save_Field (Name => COL_0_1_NAME, -- object_id |
Value => Object.Object_Id); |
Object.Clear_Modified (1); |
end if; |
if Object.Is_Modified (2) then |
Stmt.Save_Field (Name => COL_1_1_NAME, -- date |
Value => Object.Date); |
Object.Clear_Modified (2); |
end if; |
if Object.Is_Modified (3) then |
Stmt.Save_Field (Name => COL_2_1_NAME, -- counter |
Value => Object.Counter); |
Object.Clear_Modified (3); |
end if; |
if Object.Is_Modified (4) then |
Stmt.Save_Field (Name => COL_3_1_NAME, -- definition_id |
Value => Object.Get_Key); |
Object.Clear_Modified (4); |
end if; |
if Stmt.Has_Save_Fields then |
Stmt.Set_Filter (Filter => "definition_id = ? AND object_id = ? AND date = ?"); |
Stmt.Add_Param (Value => Object.Get_Key); |
Stmt.Add_Param (Value => Object.Object_Id); |
Stmt.Add_Param (Value => Object.Date); |
declare |
Result : Integer; |
begin |
Stmt.Execute (Result); |
if Result /= 1 then |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.