text
stringlengths
0
234
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation
Function Body: (Counter_Definition_Impl, Counter_Definition_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Counter_Definition_Impl_Ptr := Counter_Definition_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Counter_Definition_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_DEFINITION_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_Definition_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 ("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_Definition_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (COUNTER_DEFINITION_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- entity_type
Value => Object.Entity_Type);
Object.Clear_Modified (3);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
Function Definition: function Visit_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Function Body: Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => VISIT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Visit_Key;
function Visit_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => VISIT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Visit_Key;
function "=" (Left, Right : Visit_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";