Hola mRoman.
Te pongo un ejemplo simple para que pruebes:
Código Delphi
[-]
procedure TForm1.btCrearClick(Sender: TObject);
begin
IBSQL1.Close;
IBSQL1.SQL.Text:= 'CREATE ROLE ABCXYZ';
try
IBSQL1.ExecQuery;
IBTransaction1.CommitRetaining;
except
raise Exception.Create('Rol existente');
end;
IBSQL1.Close;
IBSQL1.SQL.Clear;
IBSQL1.SQL.Add('CREATE USER PEPITO PASSWORD ''1234''');
IBSQL1.SQL.Add('FIRSTNAME ''JOSE'' MIDDLENAME ''APOLONIO'' LASTNAME ''PEREZ''');
try
IBSQL1.ExecQuery;
IBTransaction1.CommitRetaining;
except
raise Exception.Create('Usuario existente');
end;
IBSQL1.Close;
IBSQL1.SQL.Text:= 'GRANT ABCXYZ TO PEPITO';
IBSQL1.ExecQuery;
IBTransaction1.CommitRetaining;
end;
procedure TForm1.btMostrarClick(Sender: TObject);
begin
with IBQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('SELECT RDB$USER AS USUARIO,RDB$RELATION_NAME AS ROL');
SQL.ADD('FROM RDB$USER_PRIVILEGES');
SQL.Add('WHERE RDB$RELATION_NAME = ''ABCXYZ''');
SQL.Add('ORDER BY RDB$USER');
Open;
end;
end;
procedure TForm1.btBorrarClick(Sender: TObject);
begin
IBSQL1.Close;
IBSQL1.SQL.Text:= 'DROP ROLE ABCXYZ';
try
IBSQL1.ExecQuery;
IBTransaction1.CommitRetaining;
except
raise Exception.Create('Rol inexistente');
end;
IBSQL1.Close;
IBSQL1.SQL.Text:= 'DROP USER PEPITO';
try
IBSQL1.ExecQuery;
IBTransaction1.CommitRetaining;
except
raise Exception.Create('Usuario inexistente');
end;
end;
Saludos.