我在选择语句时遇到麻烦,不确定自己在做什么错。这是源表的结构:
这是查询(我需要更改文件夹ID,因为它是从第一个查询中拉出的,因此是这样):
DECLARE
BEGIN
FOR FOLDER_ROW IN (SELECT FOLDERID = CASE
WHEN FOLDERID = '10' THEN '1'
WHEN FOLDERID = '565' THEN '2'
WHEN FOLDERID = '11' THEN '3'
WHEN FOLDERID = '81' THEN '4'
ELSE '0'
END, USERID FROM DATA1.FOLDERS WHERE UPPER(OWNER) = 'ADMIN')
LOOP
INSERT INTO DATA1.FOLDER_USER (FOLDER_ID, CORP_ID) VALUES (FOLDER_ROW.FOLDERID, FOLDER_ROW.CORPID);
END LOOP;
COMMIT;
END;
我执行时收到以下错误,但我为什么会被卡住。我知道这与select中的情况有关:
ORA-06550: line 3, column 39:
PL/SQL: ORA-00923: FROM keyword not found where expected
ORA-06550: line 3, column 22:
PL/SQL: SQL Statement ignored
最佳答案
SELECT FOLDERID = CASE错误。应该是SELECT CASE ..... END as FOLDERID