Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Procedure to Merge : SELECT from Table Of Record

1003374May 28 2013 — edited Jun 4 2013
Hi 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

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 2 2013
Added on May 28 2013
10 comments
794 views