Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE PROCEDURE aanpassing_locatie
- AS
- TYPE type_rec_uitv IS RECORD
- (cursus uitvoeringen.cursus%TYPE,
- begindatum uitvoeringen.begindatum%TYPE,
- Locatie uitvoeringen.locatie%TYPE);
- TYPE type_tab_uitv IS TABLE OF type_rec_uitv
- INDEX BY PLS_INTEGER;
- TYPE type_tab_cursus IS TABLE OF uitvoeringen.cursus%TYPE
- INDEX BY PLS_INTEGER;
- TYPE type_tab_begindatum IS TABLE OF uitvoeringen.begindatum%TYPE
- INDEX BY PLS_INTEGER;
- TYPE type_tab_locatie IS TABLE OF uitvoeringen.locatie%TYPE
- INDEX BY PLS_INTEGER;
- t_uitv type_tab_uitv;
- t_cursus type_tab_cursus;
- t_begindatum type_tab_begindatum;
- t_locatie type_tab_locatie;
- BEGIN
- SELECT cursus,begindatum,locatie BULK COLLECT INTO t_uitv
- FROM uitvoeringen
- WHERE (cursus,begindatum) IN (SELECT cursus,begindatum
- FROM inschrijvingen
- GROUP BY cursus,begindatum
- HAVING COUNT(*)>4);
- FOR i IN 1..t_uitv.LAST
- LOOP
- T_locatie(i):= 'ANTWERPEN';
- t_cursus(i):=t_uitv(i).cursus;
- t_begindatum(i):=t_uitv(i).begindatum;
- END LOOP;
- FORALL i IN 1..t_uitv.LAST
- UPDATE uitvoeringen
- SET locatie= t_locatie(i)
- WHERE cursus=t_cursus(i)
- AND begindatum=t_begindatum(i);
- END aanpassing_locatie;
- Oplossing b :
- CREATE OR REPLACE PROCEDURE aanpassing_locatie
- AS
- TYPE type_tab_uitv IS TABLE OF uitvoeringen%ROWTYPE
- INDEX BY PLS_INTEGER;
- TYPE type_tab_cursus IS TABLE OF uitvoeringen.cursus%TYPE
- INDEX BY PLS_INTEGER;
- TYPE type_tab_begindatum IS TABLE OF uitvoeringen.begindatum%TYPE
- INDEX BY PLS_INTEGER;
- t_uitv type_tab_uitv;
- t_cursus type_tab_cursus;
- t_begindatum type_tab_begindatum;
- BEGIN
- SELECT * BULK COLLECT INTO t_uitv
- FROM uitvoeringen
- WHERE (cursus,begindatum) IN (SELECT cursus,begindatum
- FROM inschrijvingen
- GROUP BY cursus,begindatum
- HAVING COUNT(*)>4);
- FOR i IN 1..t_uitv.LAST
- LOOP
- t_uitv(i).locatie:= 'ANTWERPEN';
- t_cursus(i):=t_uitv(i).cursus;
- t_begindatum(i):=t_uitv(i).begindatum;
- END LOOP;
- FORALL i IN 1..t_uitv.LAST
- UPDATE uitvoeringen
- SET ROW= t_uitv(i)
- WHERE cursus=t_cursus(i)
- AND begindatum=t_begindatum(i);
- END aanpassing_locatie;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement