Code: Select all
procedure TZDBLibConnection.SetReadOnly(Value: Boolean);
begin
//sql server and sybase do not support RO-Transaction or Sessions
//all we have is a readonly database ...
if Value then
raise EZSQLException.Create(SUnsupportedOperation);
end;
First, you get an error elsewhere than it actually makes sense (should be raised when you set TZConnection's property). I know it is not possible at that stage as the IZConnection doesn't necessarily exist.
Second, it throws a generic EZSQLException instead of EZUnsupportedException, making this indistinguishable from exception handling perspective.
#2 is easy to fix, but I started to wonder. As my workers have no idea what kind of connection they are working on (as it1s irrelevant for them) but calling SQLConnection.Connect fails, should I simply try to set .ReadOnly to false and try again? What happens if something else will throw an unsupported exception?
As there is no way to ask the driver if .ReadOnly is supported or not, there is no way to determine this beforehand (unless we hard-code it, which is a bad practice).
Should an exception be raised at all for this?
Please, feel free to throw your ideas and opinions at me :)