text stringlengths 0 234 |
|---|
end Load; |
procedure Save (Object : in out Snapshot_Impl; |
Session : in out ADO.Sessions.Master_Session'Class) is |
Stmt : ADO.Statements.Update_Statement |
:= Session.Create_Statement (SNAPSHOT_DEF'Access); |
begin |
if Object.Is_Modified (1) then |
Stmt.Save_Field (Name => COL_0_1_NAME, -- id |
Value => Object.Get_Key); |
Object.Clear_Modified (1); |
end if; |
if Object.Is_Modified (2) then |
Stmt.Save_Field (Name => COL_1_1_NAME, -- start_date |
Value => Object.Start_Date); |
Object.Clear_Modified (2); |
end if; |
if Object.Is_Modified (3) then |
Stmt.Save_Field (Name => COL_2_1_NAME, -- end_date |
Value => Object.End_Date); |
Object.Clear_Modified (3); |
end if; |
if Object.Is_Modified (5) then |
Stmt.Save_Field (Name => COL_4_1_NAME, -- host_id |
Value => Object.Host); |
Object.Clear_Modified (5); |
end if; |
if Stmt.Has_Save_Fields then |
Object.Version := Object.Version + 1; |
Stmt.Save_Field (Name => "version", |
Value => Object.Version); |
Stmt.Set_Filter (Filter => "id = ? and version = ?"); |
Stmt.Add_Param (Value => Object.Get_Key); |
Stmt.Add_Param (Value => Object.Version - 1); |
declare |
Result : Integer; |
begin |
Stmt.Execute (Result); |
if Result /= 1 then |
if Result /= 0 then |
raise ADO.Objects.UPDATE_ERROR; |
else |
raise ADO.Objects.LAZY_LOCK; |
end if; |
end if; |
Function Definition: procedure List (Object : in out Snapshot_Vector; |
Function Body: Session : in out ADO.Sessions.Session'Class; |
Query : in ADO.SQL.Query'Class) is |
Stmt : ADO.Statements.Query_Statement |
:= Session.Create_Statement (Query, SNAPSHOT_DEF'Access); |
begin |
Stmt.Execute; |
Snapshot_Vectors.Clear (Object); |
while Stmt.Has_Elements loop |
declare |
Item : Snapshot_Ref; |
Impl : constant Snapshot_Access := new Snapshot_Impl; |
begin |
Impl.Load (Stmt, Session); |
ADO.Objects.Set_Object (Item, Impl.all'Access); |
Object.Append (Item); |
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation |
Function Body: (Source_Impl, Source_Impl_Ptr); |
pragma Warnings (Off, "*redundant conversion*"); |
Ptr : Source_Impl_Ptr := Source_Impl (Object.all)'Access; |
pragma Warnings (On, "*redundant conversion*"); |
begin |
Unchecked_Free (Ptr); |
end Destroy; |
procedure Find (Object : in out Source_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, SOURCE_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 Source_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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.