我有以下代码在SQL Developer中完美运行,但我需要在APEX的进程块中输入代码,它只给我一个PL / SQL选项。以下是我写的代码:
BEGIN
truncate table TEMP_UPLOAD;
Merge into INVOICE b
USING (
SELECT CUSTOMER_CLASS,RULE_AGGREGATOR,BA
FROM CUSTOMER_TEMP_UPLOAD
WHERE CUSTOMER_CLASS = 'CUSTOMER88') u
ON (b.BA = u.BA)
WHEN MATCHED THEN UPDATE SET b.CUSTOMER88_DATE_UPDATED = sysdate
WHEN NOT MATCHED THEN
INSERT (b.CUSTOMER_CLASS,b.RULE_AGGREGATOR,b.BA,b.CUSTOMER88_DATE_ADDED)
VALUES (u.CUSTOMER_CLASS,u.RULE_AGGREGATOR,u.BA,sysdate);
UPDATE INVOICE a
SET a.CUSTOMER88_DATE_REMOVED = sysdate
WHERE BA IN
(select b.BA
from INVOICE b
left join CUSTOMER_temp_upload u
on b.BA = u.BA
where u.BA is null and b.CUSTOMER_CLASS = 'CUSTOMER88');
END;
获得以下错误
1 error has occurred
•ORA-06550: line 3, column 14: PLS-00103: Encountered the symbol "TABLE" when expecting one of the following: := . ( @ % ;
答案 0 :(得分:3)
错误消息指向您的TRUNCATE TABLE
命令。
TRUNCATE
是一个DDL命令 - 不要从PL / SQL中调用它。相反,请使用DELETE以使您的流程具有事务安全性。
(P.S。技术上可以使用EXECUTE IMMEDIATE从PL / SQL运行DDL - 但我不建议它)
答案 1 :(得分:0)
似乎问题是它不喜欢我的BEGIN和END;大写。当我把它改为开始和结束时;以及将TRUNCATE表命令更改为删除,然后接受它并且PL / SQL命令按预期工作。