desktop_task_schedule/code/db/pkg/telsaler_reward_pkg.pck

90 lines
2.1 KiB
Plaintext

CREATE OR REPLACE PACKAGE telsaler_reward_pkg IS
-- Author : WANGWEI-202
-- Created : 2023/9/13 10:05:43
-- Purpose : 坐席奖励相关的包
PROCEDURE add_telsaler_reward
(
a_reward_index VARCHAR2,
a_telsaler_name VARCHAR2
);
PROCEDURE save_telsaler_reward
(
a_rec_id INTEGER,
a_telsaler_name VARCHAR2,
a_reward_index VARCHAR2
);
PROCEDURE delete_telsaler_reward(a_rec_id INTEGER);
END telsaler_reward_pkg;
/
CREATE OR REPLACE PACKAGE BODY telsaler_reward_pkg IS
PROCEDURE add_telsaler_reward
(
a_reward_index VARCHAR2,
a_telsaler_name VARCHAR2
) IS
BEGIN
BEGIN
INSERT INTO telsaler_reward
(reward_index,
telsaler_name)
VALUES
(a_reward_index,
a_telsaler_name);
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = -00001
THEN
raise_application_error(-20001,
'值重复');
END IF;
END;
COMMIT;
END;
PROCEDURE save_telsaler_reward
(
a_rec_id INTEGER,
a_telsaler_name VARCHAR2,
a_reward_index VARCHAR2
) IS
BEGIN
MERGE INTO telsaler_reward r
USING (SELECT COUNT(*) COUNT
FROM telsaler_reward
WHERE rec_id = a_rec_id) a
ON (a.count > 0)
WHEN MATCHED THEN
UPDATE
SET r.reward_index = a_reward_index,
r.telsaler_name = a_telsaler_name
WHERE r.rec_id = a_rec_id
WHEN NOT MATCHED THEN
INSERT
(reward_index,
telsaler_name)
VALUES
(a_reward_index,
a_telsaler_name);
COMMIT;
END;
PROCEDURE delete_telsaler_reward(a_rec_id INTEGER) IS
BEGIN
DELETE telsaler_reward
WHERE rec_id = a_rec_id;
COMMIT;
END;
BEGIN
NULL;
END telsaler_reward_pkg;
/