0
someone could help me, she keeps giving error when saved '-'
Error(19,5): PLS-00103: Encountered the Symbol "CREATE" when expecting one of the following: ( start case declare quit for goto if loop mod null pragma raise return select update while with << continue closing current delete fetch lock Insert open rollback savepoint set sql execute commit forall intercalar pipe expurgar
create or replace
FUNCTION FC_CRIA_USUARIO_SADP(USERN IN VARCHAR2)
RETURN VARCHAR2
iS
RES VARCHAR2;
bd varchar2;
BEGIN
MSG:='NULL';
select USERNAME INTO RES FROM DBA_USERS
WHERE USERNNAME = USERN;
SELECT name into bd FROM V$DATABASE;
IF RES IS NULL THEN
CREATE USER USERN IDENTIFIED BY 12345678;
GRANT CREATE SESSION TO USERN;
GRANT RL_SADP_USUARIO TO USERN;
GRANT RL_ACESSO_CONSULTA TO USERN;
MSG:= 'Usuário ' || USERN ||' criado no banco' ||bd;
RETURN MSG;
ELSE
MSG:= 'Usuário ' || USERN ||' já existe no banco' ||bd;
END IF;
END FC_CRIA_USUARIO_SADP;
I think that DDL cannot be done in PLSQL , I believe the solution is to run via execute immediate vide Sample DDL Operation Using Native Dynamic SQL in https://docs.oracle.com/cd/B10501_01/appdev.920/a96590/adg09dyn.htm
– Motta