You've already forked lazarus-ccr
tvplanit: Fix Firebird datastore not writing events, contacts, tasks after creation of a new resource.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5180 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -7,6 +7,4 @@ Login parameters for the created database:
|
||||
|
||||
NOTE:
|
||||
The project creates a new database on the fly using above-menitoned login
|
||||
parameters. For reasons unknown at the moment, the first program entries after
|
||||
adding a resource are not stored --> a restart of the demo program is required
|
||||
after adding the first resource.
|
||||
parameters.
|
||||
|
@ -331,6 +331,6 @@ object Form1: TForm1
|
||||
Options = []
|
||||
Params = <>
|
||||
left = 149
|
||||
top = 511
|
||||
top = 512
|
||||
end
|
||||
end
|
||||
|
@ -79,15 +79,16 @@ begin
|
||||
|
||||
FContactsTable := TSQLQuery.Create(self);
|
||||
FContactsTable.SQL.Add('SELECT * FROM Contacts');
|
||||
FContactsTable.UpdateMode := upWhereAll;
|
||||
|
||||
FEventsTable := TSQLQuery.Create(Self);
|
||||
FEventsTable.SQL.Add('SELECT * FROM Events');
|
||||
FEventsTable.UpdateMode := upWhereAll;
|
||||
|
||||
FResourceTable := TSQLQuery.Create(self);
|
||||
FResourceTable.SQL.Add(
|
||||
'SELECT * '+
|
||||
'FROM Resources'
|
||||
);
|
||||
FResourceTable.SQL.Add('SELECT * FROM Resources');
|
||||
FResourceTable.UpdateMode := upWhereAll;
|
||||
|
||||
{
|
||||
FResourceTable.InsertSQL.Add(
|
||||
'INSERT INTO Resources (' +
|
||||
@ -102,6 +103,7 @@ begin
|
||||
}
|
||||
FTasksTable := TSQLQuery.Create(self);
|
||||
FTasksTable.SQL.Add('SELECT * FROM Tasks');
|
||||
FTasksTable.UpdateMode := upWhereAll;
|
||||
end;
|
||||
|
||||
procedure TVpFirebirdDatastore.AddField(ATableName, AFieldName: String;
|
||||
@ -517,24 +519,32 @@ end;
|
||||
Firebird will complain about this field not being specified when posting. }
|
||||
procedure TVpFirebirdDatastore.OpenTables;
|
||||
begin
|
||||
{
|
||||
if FContactsTable.Transaction = nil then
|
||||
FContactsTable.Transaction := FConnection.Transaction;
|
||||
}
|
||||
FixContactsTable;
|
||||
FContactsTable.Open;
|
||||
FContactsTable.Fields[0].Required := false;
|
||||
|
||||
{
|
||||
if FEventsTable.Transaction = nil then
|
||||
FEventsTable.Transaction := FConnection.Transaction;
|
||||
}
|
||||
FEventsTable.Open;
|
||||
FEventsTable.Fields[0].Required := false;
|
||||
|
||||
{
|
||||
if FResourceTable.Transaction = nil then
|
||||
FResourceTable.Transaction := FConnection.Transaction;
|
||||
}
|
||||
FResourceTable.Open;
|
||||
FResourceTable.Fields[0].Required := false;
|
||||
|
||||
{
|
||||
if FTasksTable.Transaction = nil then
|
||||
FTasksTable.Transaction := FConnection.Transaction;
|
||||
}
|
||||
FTasksTable.Open;
|
||||
FTasksTable.Fields[0].Required := false;
|
||||
end;
|
||||
@ -543,24 +553,35 @@ procedure TVpFirebirdDatastore.PostContacts;
|
||||
begin
|
||||
inherited;
|
||||
FContactsTable.ApplyUpdates;
|
||||
FConnection.Transaction.CommitRetaining;
|
||||
FContactsTable.Refresh;
|
||||
end;
|
||||
|
||||
procedure TVpFirebirdDatastore.PostEvents;
|
||||
begin
|
||||
inherited;
|
||||
FEventsTable.ApplyUpdates;
|
||||
FConnection.Transaction.CommitRetaining;
|
||||
FEventsTable.Refresh;
|
||||
end;
|
||||
|
||||
procedure TVpFirebirdDatastore.PostResources;
|
||||
begin
|
||||
inherited;
|
||||
FResourceTable.ApplyUpdates;
|
||||
FConnection.Transaction.CommitRetaining;
|
||||
// Refresh needed in order to get the resource id for the other tables.
|
||||
// Without it the other datasets would not be stored after adding a resource.
|
||||
// Seems to be pecularity of Firebird.
|
||||
FResourceTable.Refresh;
|
||||
end;
|
||||
|
||||
procedure TVpFirebirdDatastore.PostTasks;
|
||||
begin
|
||||
inherited;
|
||||
FTasksTable.ApplyUpdates;
|
||||
FConnection.Transaction.CommitRetaining;
|
||||
FTasksTable.Refresh;
|
||||
end;
|
||||
|
||||
procedure TVpFirebirdDatastore.SetConnected(const AValue: Boolean);
|
||||
|
Reference in New Issue
Block a user