/
CREATE OR REPLACE PROCEDURE NEW_JOB_PROC
(
--param
P_JOB_ID IN JOBS.JOB_ID%TYPE,
P_JOB_TITLE IN JOBS.JOB_TITLE%TYPE,
P_MIN_SALARY IN JOBS.MIN_SALARY%TYPE,
P_MAX_SALARY IN JOBS.MAX_SALARY%TYPE
)
is
BEGIN
MERGE INTO JOBS J
USING (SELECT COUNT(*) CNT FROM JOBS WHERE JOB_ID =P_JOB_ID) I
on (i.cnt =1)
WHEN MATCHED THEN
UPDATE SET
J.JOB_TITLE = P_JOB_TITLE,
J.MIN_SALARY = P_MIN_SALARY,
J.MAX_SALARY = P_MAX_SALARY
WHERE J.JOB_ID = P_JOB_ID
when not matched then
INSERT
(j.JOB_ID, j.JOB_TITLE, j.MIN_SALARY, j.MAX_SALARY)
VALUES
(P_JOB_ID, P_JOB_TITLE, P_MIN_SALARY, P_MAX_SALARY);
commit;
END;
/
show err;
/
EXEC NEW_JOB_PROC('sample','sample',2000,2000);
select * from jobs where job_id = 'sample';
'DB' 카테고리의 다른 글
oracle plan 확인 hint (0) | 2024.05.20 |
---|---|
[pl/sql] procedure return (0) | 2020.10.20 |
[pl/sql]procedure in out param (0) | 2020.10.20 |
[pl/sql] procedure default value setting (0) | 2020.10.20 |
[pl/sql] insert or update procedure (0) | 2020.10.20 |