I am having trouble with a select statement and not sure what I am doing wrong. This is the structure of the source table:
Source Schema DATA1
Source Table FOLDERS
Source Columns FOLDERID, USERID
Destination Schema DATA1
Destination Table FOLDER_USER
Destination Columns FOLDER_ID, USER_ID
And here is the query ( I need to change the folder ID as it is being pulled out of the first query hence the case):
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;
I get the following error when I execute and I’m stuck as to why I am getting it. I know it has something to do with the case inside the 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 is wrong. It should be SELECT CASE ….. END As FOLDERID