thanks for helping me. The first insert works OK but the second doesnt insert anything. Can you help me please. Im learning plsql but there is still some things i dont know.
PROCEDURE PR_INS_INVESTIGATION (
PIN_INS_INVESTIGATION IN IN_INS_INVESTIGATION)
IS
LST_INS_INVESTIGATED RC_INS_INVESTIGATED;
EX_NO_DATA EXCEPTION;
BEGIN
INSERT INTO PQR076INVESTIGATION (CCPQR076IDINVESTIGATION,
CCPQR076DATE,
CCPQR076AREA,
CCPQR076STATE,
CCPQR076USER)
VALUES (PIN_INS_INVESTIGATION.IDINVESTIGACION,
SYSDATE,
PIN_INS_INVESTIGATION.AREA,
PIN_INS_INVESTIGATION.STATE,
USER);
COMMIT;
IF LST_INS_INVESTIGATED IS NOT NULL
AND LST_INS_INVESTIGATED.COUNT > 0
THEN
FOR j IN LST_INS_INVESTIGATED.FIRST .. LST_INS_INVESTIGATED.LAST
LOOP
INSERT INTO PQR075INVESTIGATED (CCPQR075IDINVESTIGATION,
CCPQR075NIDENT,
CCPQR075NAME,
CCPQR075USER)
VALUES (PIN_INS_INVESTIGATION.IDINVESTIGAtION,
LST_INS_INVESTIGATED (J).NUMBERID,
LST_INS_INVESTIGATED (J).NAME,
USER);
COMMIT;
END LOOP;
END IF;
END;
This is the way im testing the procedure:
´´´
declare
pin_ins_investigation in_ins_investigation;
begin
pin_ins_investigation := in_ins_investigation();
pin_ins_investigation.IDinvestigation := '1234460';
pin_ins_investigation.AREA := '05';
pin_ins_investigation.STATE := 'E';
pin_ins_investigation.LST_INS_investigated.extend;
pin_ins_investigation.LST_INS_investigated(1).NUMBERID := '1014350360';
pin_ins_investigation.LST_INS_investigated(1).NAME := 'PETER TOSH';
pkg_package.pr_ins_investigation(pin_ins_investigation => pin_ins_investigation);
end;
´´´
The way I see it, this:
IF LST_INS_INVESTIGATED IS NOT NULL
AND LST_INS_INVESTIGATED.COUNT > 0
is never true so nothing within the IF - END IF
block is ever executed.
You declared it as
LST_INS_INVESTIGATED RC_INS_INVESTIGATED;
but lst_ins_investigated
doesn't contain anything, it is just declared, never populated with any values. Once you fix that, code might work.