mirror of
https://github.com/kucherenko/jscpd.git
synced 2026-09-19 08:11:03 +08:00
64e471e2b0
Adds 92 new tests (178 → 270 total) with zero source-file modifications: - packages/finder: 13 new test files covering all reporters, subscribers, validators, hooks, utils, options, cloneFound, getFilesToDetect, and InFilesDetector; shared buildClone() factory helper - apps/jscpd: 3 new test files (options-unit, print, store) plus extensions to formats, modes, and options integration tests - vitest.config.ts added to both packages to restrict coverage.include to src/** only, eliminating bin/ and prism.js noise - Fixes 3 tokenizer bugs (trailing space in format lookup, tokenization edge cases) uncovered by the new format fixture suite - Adds fixture files for 40+ language formats to support formats.test.ts
87 lines
2.2 KiB
Plaintext
87 lines
2.2 KiB
Plaintext
-- PL/SQL Package for employee management
|
|
CREATE OR REPLACE PACKAGE emp_mgmt AS
|
|
PROCEDURE hire_employee(
|
|
p_first_name IN VARCHAR2,
|
|
p_last_name IN VARCHAR2,
|
|
p_email IN VARCHAR2,
|
|
p_department IN VARCHAR2,
|
|
p_salary IN NUMBER,
|
|
p_emp_id OUT NUMBER
|
|
);
|
|
|
|
PROCEDURE update_salary(
|
|
p_emp_id IN NUMBER,
|
|
p_new_salary IN NUMBER
|
|
);
|
|
|
|
FUNCTION get_employee_count(
|
|
p_department IN VARCHAR2
|
|
) RETURN NUMBER;
|
|
END emp_mgmt;
|
|
/
|
|
|
|
CREATE OR REPLACE PACKAGE BODY emp_mgmt AS
|
|
|
|
PROCEDURE hire_employee(
|
|
p_first_name IN VARCHAR2,
|
|
p_last_name IN VARCHAR2,
|
|
p_email IN VARCHAR2,
|
|
p_department IN VARCHAR2,
|
|
p_salary IN NUMBER,
|
|
p_emp_id OUT NUMBER
|
|
) IS
|
|
v_dept_id NUMBER;
|
|
BEGIN
|
|
SELECT department_id INTO v_dept_id
|
|
FROM departments
|
|
WHERE department_name = p_department;
|
|
|
|
INSERT INTO employees (
|
|
first_name, last_name, email,
|
|
department_id, salary, hire_date
|
|
) VALUES (
|
|
p_first_name, p_last_name, p_email,
|
|
v_dept_id, p_salary, SYSDATE
|
|
) RETURNING employee_id INTO p_emp_id;
|
|
|
|
COMMIT;
|
|
DBMS_OUTPUT.PUT_LINE('Hired employee: ' || p_emp_id);
|
|
EXCEPTION
|
|
WHEN NO_DATA_FOUND THEN
|
|
RAISE_APPLICATION_ERROR(-20001, 'Department not found: ' || p_department);
|
|
WHEN DUP_VAL_ON_INDEX THEN
|
|
RAISE_APPLICATION_ERROR(-20002, 'Email already exists: ' || p_email);
|
|
END hire_employee;
|
|
|
|
PROCEDURE terminate_employee(
|
|
p_emp_id IN NUMBER,
|
|
p_termination_dt IN DATE DEFAULT SYSDATE
|
|
) IS
|
|
BEGIN
|
|
UPDATE employees
|
|
SET status = 'TERMINATED',
|
|
termination_date = p_termination_dt,
|
|
last_modified = SYSDATE
|
|
WHERE employee_id = p_emp_id;
|
|
|
|
IF SQL%ROWCOUNT = 0 THEN
|
|
RAISE_APPLICATION_ERROR(-20003, 'Employee not found: ' || p_emp_id);
|
|
END IF;
|
|
COMMIT;
|
|
END terminate_employee;
|
|
|
|
FUNCTION get_employee_count(
|
|
p_department IN VARCHAR2
|
|
) RETURN NUMBER IS
|
|
v_count NUMBER;
|
|
BEGIN
|
|
SELECT COUNT(*) INTO v_count
|
|
FROM employees e
|
|
JOIN departments d ON e.department_id = d.department_id
|
|
WHERE d.department_name = p_department;
|
|
RETURN v_count;
|
|
END get_employee_count;
|
|
|
|
END emp_mgmt;
|
|
/
|