PLS-00103:在期望以下之一时遇到符号 "BEGIN":“ := . ( @ % ;”
PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: " := . ( @ % ;"
我有这个代码
BEGIN TRANSACTION
BEGIN TRY
INSERT INTO table2 (field1, field2, field3, field4)
SELECT '1', field2, field3, field4
FROM table1
COMMIT
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
我得到以下错误
SQL Error [6550] [65000]: ORA-06550: line 2, column 2:
PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:
:= . ( @ % ;
我已经尝试并寻找关于同一主题的多个问题,但我找不到答案,也许这里有什么事情让我头疼。使用 ;在每个句子给我不同的错误之后
更新:
以下错误消息以此代码结尾:
BEGIN TRANSACTION;
BEGIN TRY;
INSERT INTO table2 (field1, field2, field3, field4)
SELECT '1', field2, field3, field4
FROM table1
COMMIT ;
END TRY;
BEGIN CATCH;
ROLLBACK TRANSACTION;
END CATCH;
并出现以下错误:
SQL Error [6550] [65000]: ORA-06550: line 13, column 10:
PL/SQL: ORA-02181: invalid option to ROLLBACK WORK
ORA-06550: line 13, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 15, column 10:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
( begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quote
错误请一一解决。对于您提到的错误,保留一个';'在 'BEGIN TRANSACTION' 之后编译并检查。然后根据进一步的错误,您可以检查哪一行需要修复,或者需要修复什么错误。希望方法对您有所帮助。
您发布的代码 不是 Oracle,而您收到的错误消息 是 所以我认为您真的使用 Oracle。在那种情况下,你会
begin
insert into table2 (field1, field2, field3, field4)
select '1', filed2, field3, field4
from table1;
commit;
end;
/
如果出现错误,实际上不会插入任何内容,因此无需回滚。如果需要,您可以处理异常,例如
begin
insert into table2 (field1, field2, field3, field4)
select '1', filed2, field3, field4
from table1;
commit;
exception
when dup_val_on_index then
null;
when others then
raise;
end;
我有这个代码
BEGIN TRANSACTION
BEGIN TRY
INSERT INTO table2 (field1, field2, field3, field4)
SELECT '1', field2, field3, field4
FROM table1
COMMIT
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
我得到以下错误
SQL Error [6550] [65000]: ORA-06550: line 2, column 2:
PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:
:= . ( @ % ;
我已经尝试并寻找关于同一主题的多个问题,但我找不到答案,也许这里有什么事情让我头疼。使用 ;在每个句子给我不同的错误之后
更新:
以下错误消息以此代码结尾:
BEGIN TRANSACTION;
BEGIN TRY;
INSERT INTO table2 (field1, field2, field3, field4)
SELECT '1', field2, field3, field4
FROM table1
COMMIT ;
END TRY;
BEGIN CATCH;
ROLLBACK TRANSACTION;
END CATCH;
并出现以下错误:
SQL Error [6550] [65000]: ORA-06550: line 13, column 10:
PL/SQL: ORA-02181: invalid option to ROLLBACK WORK
ORA-06550: line 13, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 15, column 10:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
( begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quote
错误请一一解决。对于您提到的错误,保留一个';'在 'BEGIN TRANSACTION' 之后编译并检查。然后根据进一步的错误,您可以检查哪一行需要修复,或者需要修复什么错误。希望方法对您有所帮助。
您发布的代码 不是 Oracle,而您收到的错误消息 是 所以我认为您真的使用 Oracle。在那种情况下,你会
begin
insert into table2 (field1, field2, field3, field4)
select '1', filed2, field3, field4
from table1;
commit;
end;
/
如果出现错误,实际上不会插入任何内容,因此无需回滚。如果需要,您可以处理异常,例如
begin
insert into table2 (field1, field2, field3, field4)
select '1', filed2, field3, field4
from table1;
commit;
exception
when dup_val_on_index then
null;
when others then
raise;
end;