I am trying to create an insert statement based off of a loop but I am getting PLS-00103 Encountered the symbol "end of file" when expecting one of the following: ;
The point of the script is to select all IDs from another table based on the value of another field in a joined table and then insert those IDs into a second table, one row at a time of course.
Here is what I have so far and I'm not sure why I get the error. The line number points to the last CURRENT_DATE entry.
BEGIN
For v_apv_cmp_id IN (
select distinct
paa.APV_CMP_ID
from APV_APVR paa
join APV_CMP pac on pac.apv_cmp_id = paa.apv_cmp_id
join SEC_DISPLAY ssd on ssd.app_level_id = pac.app_level_id
where ssd.field_table_name = 'application_name'
)
LOOP
INSERT INTO APV_APVR
(APV_APVR_ID, APV_CMP_ID, APVR_USR_ID, ORG_USR_ACV_TS, ORG_USR_NU, LTS_UPD_USR_NU, LTS_UPD_USR_TS)
values (
(
select MAX(APV_APVR_ID)+1 from APV_APVR
)
, v_apv_cmp_id
, 'tssao18'
, 'tssetac'
, CURRENT_DATE
, 'tssetac'
, CURRENT_DATE
);
END LOOP;
END;
v_apv_cmp_id
as ID is a little bit suspicious. Try to replace it withv_apv_cmp_id.apv_cmp_id
. – Toru