oracle MERGE into 的寫法(1)

CREATE OR REPLACE PROCEDURE P_MERGE_MMCTP(ORDERID VARCHAR2, FLAG VARCHAR2) AS
BEGIN
  IF (FLAG = 'S') THEN    MERGE INTO ctp A
    USING (SELECT 001             FROM a_FILE
            WHERE 001 = ORDERID) B
    ON (A.001 = B.001)
    WHEN MATCHED THEN
      UPDATE SET A.001= A.001 + 1
    WHEN NOT MATCHED THEN
      INSERT (001) VALUES (ORDERID);
  ELSIF (FLAG = 'R') THEN

    UPDATE TC_MMCTP_FILE
       SET 003= 003+ 1
     WHERE 001= ORDERID;
    COMMIT;
  END IF;
END P_MERGE_MMCTP;

posted on 2011-04-07 09:40  Mayvar  阅读(217)  评论(0编辑  收藏  举报

导航