· 9 years ago · Oct 06, 2016, 07:02 AM
1DECLARE
2USER_COUNT INTEGER;
3BEGIN
4 SELECT COUNT(*) INTO USER_COUNT FROM dba_users WHERE username=?;
5 IF (USER_COUNT = 0) THEN
6 EXECUTE IMMEDIATE 'CREATE USER ? IDENTIFIED BY ?';
7 EXECUTE IMMEDIATE 'GRANT CREATE SESSION, CREATE TABLE, CREATE ANY INDEX TO ?';
8 ELSE
9 raise_application_error(-20101, 'User ? already exists. Please drop it or choose another username.');
10 END IF;
11END;
12/
13
14EXECUTE IMMEDIATE 'CREATE USER ? IDENTIFIED BY ?';
15
16EXECUTE IMMEDIATE CREATE USER ? IDENTIFIED BY ?;
17
18java.sql.SQLException: ORA-06550: line 6, column 23:
19PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
20
21 ( - + case mod new not null <an identifier>
22 <a double-quoted delimited-identifier> <a bind variable>
23 continue avg count current exists max min prior sql stddev
24 sum variance execute forall merge time timestamp interval
25 date <a string literal with character set specification>
26 <a number> <a single-quoted SQL string> pipe
27 <an alternatively-quoted string literal with character set specification>
28 <an alternat