我在選擇語句時遇到問題,不確定我做錯了什麼。這是源表的結構:SQL選擇和案例相結合
源架構DATA1
源表FOLDERS
源列FOLDERID,USERID
目標架構DATA1
目標表FOLDER_USER
目標列FOLDER_ID,USER_ID
這裏是查詢(我需要更改文件夾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;
我收到以下錯誤,當我執行和我堅持爲什麼我得到它。我知道它與選擇內的情況有關:
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
爲什麼這麼複雜?這可以通過直接使用INSERT ... SELECT來完成。這會很快**。 –