can anyone tell me how I can insert multiple rows in a trigger. I have tried multiple ways and so far nothing works.
create or replace
TRIGGER USER_GROUPS_TRIG
before INSERT ON USER_GROUPS
FOR EACH ROW
DECLARE
max_id number;
BEGIN
SELECT TO_NUMBER(new_id ) +1 as new_id into max_id FROM NEW_ID_VW;
INSERT INTO TBL1
(USER, NAME) VALUES
(max_id , :NEW.NEW); --this works fine and needs no adjustment, 1 row inserted.
MERGE INTO GROUP_MAPPING A
USING (SELECT USER_ID,GROUP_ID FROM ADMIN_GROUPS_VW) B
ON (A.USER_ID=B.USER_ID)
WHEN NOT MATCHED THEN
INSERT (A.USER_ID,A.GROUP_ID)
values (b.user_id,b.group_id);
--FOR V IN 1..10 LOOP
-- INSERT INTO GROUP_MAPPING (user_id,group_id)
-- (select user_id,group_id from admin_groups_vw);
-- END LOOP;
--INSERT INTO GROUP_MAPPING
-- (USER_ID, GROUP_ID) VALUES
--(max_id ,(select group_id from admin_groups_vw));
--none of these pop an error, just doesnt do the insert (there is multiple records so there should be multipe rows inserted) , i tried insert, loop, and merge.
END;
Thanks for any help.