Procedure to Merge : SELECT from Table Of Record
1003374May 28 2013 — edited Jun 4 2013Hi there,
I want to write a simple stored procedure and I want to keep it as simple as possible (no loop, the least amount of parameters ...etc.)
Basically, the procedure receives a Talbe Of Record as input parameters and needs to merge it with existing table, the table of record is of the rowtype of the existing table.
I have difficulties to merge these data. Below is what I tried
CREATE or REPLACE PACKAGE BIZ_xxx_MERGE
IS
TYPE xxx_ACTIVITE_Type IS TABLE OF MyTbl%RowType INDEX BY BINARY_INTEGER;
PROCEDURE MERGE_xxx_ACTIVITE_SP (
MyLP IN xxx_ACTIVITE_Type
);
END BIZ_xxx_MERGE;
CREATE OR REPLACE PACKAGE BODY BIZ_xxx_MERGE AS
PROCEDURE MERGE_xxx_ACTIVITE_SP (
MyLP IN xxx_ACTIVITE_Type
) AS
BEGIN
MERGE INTO MyTbl
USING (MyLP) S -- <= WHAT TO DO HERE
ON (MyTbl.xxx_ACTCD = S.xxx_ACTCD)
WHEN NOT MATCHED THEN
INSERT (xxx_ACTCD, xxx_LIBL)
VALUES (S.xxx_ACTCD, s.xxx_LIBL);
END MERGE_xxx_ACTIVITE_SP;
END BIZ_xxx_MERGE;
Any idea? Is there any better way?
Thanks
Edited by: BizTalk Guy on 28 mai 2013 07:37