你能说出这段代码有什么问题吗?
出现编译错误错误:
PL / SQL:ORA-00933:SQL命令未正确结束
文本:
IF iCnt > 0 THEN
WITH S600 AS (
Prod_KEY NUMBER;
iCount NUMBER;
BEGIN
WITH TEMP_All AS
(SELECT * FROM TEMP1
UNION ALL
SELECT * FROM TEMP2
UNION ALL
SELECT * FROM TEMP3)
SELECT COUNT(*)
INTO iCount
FROM TEMP_ALL
IF iCount > 0 THEN
TEMP_OUT AS(
SELECT Key1, count(*) as cnt
FROM TEMP_ALL),
TempKey AS(
SELECT BarSuid FROM TEMP_OUT
WHERE cnt = (SELECT MAX(cnt) FROM TEMP_OUT));
ELSE
TempKey AS(
SELECT Key1 FROM PRODUCT
WHERE Key1 NOT IN ( SELECT Key1 FROM PRODUCT_DET));
END IF;
SELECT key2
INTO PROD_KEY
FROM PRODUCT,TempKey
WHERE PRODUCT.Key1 = TempKey.Key1
AND TempKey.Key1 IS NOT NULL;
EXCEPTION
WHEN OTHERS
THEN
dbms_output.put_line(SQLCode);
END;
答案 0 :(得分:2)
我不知道这只是一个更大程序的一部分还是什么,你问题中的标记有点令人困惑。
无论如何,我能注意到你在第一个 SELECT 结束时忘记了分号(;)。它应该是:
SELECT COUNT(*)
INTO iCount
FROM TEMP_ALL;
答案 1 :(得分:1)
“WITH S600 AS (
”启动一条SQL语句,但后面的内容(“Prod_KEY NUMBER; iCount NUMBER;
”)是PL / SQL。此外,WITH不用于声明SQL语句 - 您可能正在考虑使用“CURSOR xxx IS SELECT ...;
”声明的显式游标。
您的PL / SQL块需要以DECLARE开头。 e.g:
DECLARE
Prod_KEY NUMBER; iCount NUMBER;
BEGIN
SELECT COUNT(*)
INTO iCount
FROM (SELECT * FROM TEMP1
UNION ALL SELECT * FROM TEMP2
UNION ALL SELECT * FROM TEMP3);
IF iCount > 0 THEN ...
我认为你应该可以从那里拿走它。