1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| CREATE OR REPLACE PROCEDURE my_new_job_proc (p_job_id IN JOBS.JOB_ID%TYPE , p_job_title IN JOBS.JOB_TITLE%TYPE , p_min_sal IN JOBS.MIN_SALARY%TYPE := 10 , p_max_sal IN JOBS.MAX_SALARY%TYPE := 100 , p_upd_date OUT JOBS.UPDATE_DATE%TYPE ) IS vn_cnt NUMBER := 0; vn_cur_date JOBS.UPDATE_DATE%TYPE := SYSDATE; BEGIN SELECT COUNT(*) INTO vn_cnt FROM JOBS WHERE job_id = p_job_id; IF vn_cnt = 0 THEN INSERT INTO JOBS(job_id , job_title , min_salary , max_salary , create_date , update_date) VALUES(p_job_id, p_job_title, p_min_sal, p_max_sal, vn_cur_date, vn_cur_date); ELSE UPDATE JOBS SET job_title = p_job_title , min_salary = p_min_sal , max_salary = p_max_sal , update_date = vn_cur_date WHERE job_id = p_job_id; END IF; p_upd_date := vn_cur_date; COMMIT; END;
SET SERVEROUTPUT ON DECLARE vd_cur_date JOBS.UPDATE_DATE%TYPE; BEGIN my_new_job_proc('SM_JOB1', 'Sample JOB1', 2000, 6000, vd_cur_date); DBMS_OUTPUT.PUT_LINE(vd_cur_date); END;
|