我遇到了一个oracle错误,
ORA-00933:SQL命令未正确结束
随着以下内容。
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')
/
我在每个语句的末尾"/"之前添加了分号。
有什么建议我可能错了吗?
您没有发布CREATE TABLE
语句,所以我自己发布了。
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>
让我们以完全复制/粘贴的方式运行您发布的insert
语句(我没有更改任何内容(:
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>
显然,它们都能工作,并且没有引发ORA-00933
(SQL命令未正确结束(。因此,要么你没有发布你应该拥有的一切,要么你误解了现实。