Hi everybody,
for a script which should create a database user for monitoring database structures over Grafana I will create a script which I can use everytime when I rollout the user on a new server or I change the grants.
In case of that I'm trying to create a PL/SL block, which looks if the user is available or not. I user isn't there it should be created, if user is already there the password has to be changed so that all databases has the same login for the grafana database user. Actually I'm at this point:
declare
userexist integer;
begin
select count(*) into userexist from dba_users where username='GRAFANA';
if userexist = 0 then execute immediate 'CREATE USER GRAFANA IDENTIFIED BY "grafana" DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;';
else execute immediate 'ALTER USER GRAFANA IDENTIFIED BY "grafana";';
end if;
end;
/
But each time, when I execute my code I get this:
declare
userexist integer;
begin
select count(*) into userexist from dba_users where username='GRAFANA';
if userexist = 0 then execute immediate 'CREATE USER GRAFANA IDENTIFIED BY "grafana" DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;';
else execute immediate 'ALTER USER GRAFANA IDENTIFIED BY "grafana" ;';
end if;
end;
9 /
declare
*
ERROR at line 1:
ORA-00922: missing or invalid option
ORA-06512: at line 6
But I didn't get why? I've read out the docu again and again but where is the problem with the "else" part? The error should be in the "else" part because when I comment the else part the block is working w.o. any problems...
So am I blind?
Thanks and regards,
David