There are cases where I want to change a number of records and I use an UPDATE in SQL like the following:
UPDATE musicalbums SET olds=1 WHEN year(issuedate)<2000;
Is that possible through Aurelius?
There are cases where I want to change a number of records and I use an UPDATE in SQL like the following:
UPDATE musicalbums SET olds=1 WHEN year(issuedate)<2000;
Is that possible through Aurelius?
I'd say: No, it's not possible.
You would have to load all objects meeting your criteria, change each one of them, than flush the changes (to execute an update for each id).
I find more eficient to just execute the sql using IDBStatement
var
Con: IDBConnection;
Trs: IDBTransaction;
Stt: IDBStatement;
N: Integer;
begin
Con := YourMethodToGetAConnection;
Tra := Con.BeginTransaction;
try
Stt := Con.CreateStatement;
Stt.SetSQLCommand('UPDATE musicalbums SET olds=1 WHEN year(issuedate)<2000');
N := Stt.Execute; // N is the number of records affected by the UPDATE
finally
Tra.Commit;
end;
Regards,