oracle-databaseora-00933

Oracle : ORA-00933: SQL command not properly ended


I'm running into an oracle error,

ORA-00933: SQL command not properly ended

With the follwing.

insert into TableOne (name, description, scopeid, readonly)
Select 'access', 'Some Description', 0, 0 from dual
where not exists(SELECT * FROM Privilege WHERE name = 'access')
/
insert into TableTwo (name, uuid, description, scopeid) 
Select 'Role','ROLE_UUID','Another description.', 0 from dual
where not exists(SELECT * FROM Role WHERE uuid = 'ROLE_UUID')
/

I have added semicolons at the end of each statement before the '/'.

Any suggestions where I may be wrong?


Solution

  • You didn't post CREATE TABLE statements so I did that myself.

    SQL> create table privilege as
      2    select 'some name' name from dual;
    
    Table created.
    
    SQL> create table role as
      2    select 'some UUID' uuid from dual;
    
    Table created.
    
    SQL> create table tableone
      2    (name        varchar2(10),
      3     description varchar2(20),
      4     scopeid     number,
      5     readonly    number);
    
    Table created.
    
    SQL> create table tabletwo
      2    (name        varchar2(10),
      3     uuid        varchar2(10),
      4     description varchar2(20),
      5     scopeid     number);
    
    Table created.
    
    SQL>
    

    Let's run insert statements you posted as exact copy/paste (I didn't change anything):

    SQL> insert into TableOne (name, description, scopeid, readonly)
      2  Select 'access', 'Some Description', 0, 0 from dual
      3  where not exists(SELECT * FROM Privilege WHERE name = 'access')
      4  /
    
    1 row created.
    
    SQL> insert into TableTwo (name, uuid, description, scopeid)
      2  Select 'Role','ROLE_UUID','Another description.', 0 from dual
      3  where not exists(SELECT * FROM Role WHERE uuid = 'ROLE_UUID')
      4  /
    
    1 row created.
    
    SQL>
    

    Apparently, both of them work and no ORA-00933 (SQL command not properly ended) is raised. Therefore, either you didn't post everything you should have, or you're misinterpreting reality.