2

Aqua DataStudio8.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:遭遇しました次のいずれかが必要な場合の記号「ファイルの終わり」:

:=(; null以外の範囲デフォルト文字スクリプト行3、ステートメント行3、列41

4

2 に答える 2

2

これが(スクリプトとして)実行されている方法によっては、PLSQLブロックをスラッシュで終了する必要がある場合があります。

declare
--...
begin
--...
end;
/

また、コードがそのまま動作する必要があることを示すために(Oracle 11GR2の場合、SQL Developerからのスクリプト出力では、create orselectステートメントの後のセミコロンや行の後のスラッシュは表示されません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 
于 2012-05-30T19:02:34.273 に答える
0

引用符を削除してみてください。なぜそこにあるのかわからない

于 2012-05-30T18:52:49.310 に答える