我正在尝试在Aqua Data Studio 8.0.22中执行下一个代码:
-- Add a new role for cashier.
declare
roleEntityID "Entity"."EntityID"%type;
begin
select "EntityID_SEQ".NEXTVAL into roleEntityID from dual;
insert into "Entity" ("EntityID") values(roleEntityID);
insert into "Role" ("RoleID", "Name", "DisplayName") values (roleEntityID, 'Cashier', 'Cashier');
end;
但不幸的是我遇到了一些错误,首先是:
[错误]脚本行:1-3 -------------------------- ORA-06550:第3行,第41栏:PLS- 00103:遇到符号“文件结束”时 期待以下之一:
:=(;不是空范围默认字符脚本第3行,语句 第3行,第41栏
答案 0 :(得分:2)
根据运行方式(作为脚本?),您可能需要使用正斜杠结束PLSQL块:
declare
--...
begin
--...
end;
/
并向您展示您的代码应该完全按原样运行(在Oracle 11GR2上; SQL Developer的脚本输出显然不会在create
或select
语句之后显示分号或end;
之后的行上的斜线,但原始缓冲区中都存在斜线):
> create sequence "EntityID_SEQ"
sequence "EntityID_SEQ" created.
> create table "Entity"("EntityID" number)
table "Entity" created.
> create table "Role"("RoleID" number, "Name" varchar2(30), "DisplayName" varchar2(30))
table "Role" created.
> declare
roleEntityID "Entity"."EntityID"%type;
begin
select "EntityID_SEQ".NEXTVAL into roleEntityID from dual;
insert into "Entity" ("EntityID") values(roleEntityID);
insert into "Role" ("RoleID", "Name", "DisplayName") values (roleEntityID, 'Cashier', 'Cashier');
end;
anonymous block completed
> select * from "Entity"
EntityID
----------------------
1
1 rows selected
> select * from "Role"
RoleID Name DisplayName
---------------------- ------------------------------ ------------------------------
1 Cashier Cashier
1 rows selected
答案 1 :(得分:0)
尝试删除引号。不知道你为什么要把它们放在那里