I have a collection of type table in PLSQL begin block and I had to use it multiple time in my code.
I there any way to use the list (table type) in SELECT statement? My goal is to write less code.
I have included the array (TABLE) directly inside the SELECT statement
Bellow script is shown what I'm trying to do, but apparently, I can no do that, because we can't use collections in SQL statement (Please check the delete statement).
clear Screen
SET SERVEROUTPUT ON
SET linesize 300
SET timing ON
WHENEVER SQLERROR EXIT failure ROLLBACK;
WHENEVER oserror EXIT failure ROLLBACK;
DECLARE
code_groupe VARCHAR2 (50 CHAR);
code_grp VARCHAR2 (4 CHAR);
TYPE arrayList is table of varchar2(50);
site_code_ls arrayList;
BEGIN
code_grp := 'ABDE';
site_code_ls := arrayList ('D','C','B','A','L');
DELETE CARP.PLACES_GROUPS
WHERE CODE_GROUPE = code_grp AND CODE_PLACE NOT IN (SELECT S.CODE
FROM CARP.PLACE P
WHERE P.CODE_IMPLANTATION IN site_code_ls;
COMMIT;
END;
/
exit;