在Delphi中,你如何才能最终使用try,并一起使用?Java/C#等价物看起来像:
try {
// Open DB connection, start transaction
} catch (Exception e) {
// Roll back DB transaction
} finally {
// Close DB connection, commit transaction
}
Run Code Online (Sandbox Code Playgroud)
如果你在Delphi中尝试这个,你可以使用try/finally或try/except; 但从来没有三个在一起.我想代码如下(不编译):
try
// Open DB connection, start transaction
except on e: Exception do
begin
// Roll back transaction
end
finally // Compiler error: expected "END" not "finally"
begin
// Commit transaction
end
Run Code Online (Sandbox Code Playgroud)