- CREATE OR REPLACE PACKAGE emp_actions
- AS -- package specification
- PROCEDURE hire_employee (employee_id NUMBER,
- last_name VARCHAR2,
- first_name VARCHAR2,
- email VARCHAR2,
- phone_number VARCHAR2,
- hire_date DATE,
- job_id VARCHAR2,
- salary NUMBER,
- commission_pct NUMBER,
- manager_id NUMBER,
- department_id NUMBER);
- PROCEDURE fire_employee (emp_id NUMBER);
- FUNCTION num_above_salary (emp_id NUMBER)
- RETURN NUMBER;
- END emp_actions;
- /
- /* Formatted on 2012-07-27 15:24:06 (QP5 v5.114.809.3010) */
- CREATE OR REPLACE PACKAGE BODY emp_actions
- AS -- package body
- -- code for procedure hire_employee
- PROCEDURE hire_employee (employee_id NUMBER,
- last_name VARCHAR2,
- first_name VARCHAR2,
- email VARCHAR2,
- phone_number VARCHAR2,
- hire_date DATE,
- job_id VARCHAR2,
- salary NUMBER,
- commission_pct NUMBER,
- manager_id NUMBER,
- department_id NUMBER)
- IS
- BEGIN
- INSERT INTO employees
- VALUES (employee_id,
- last_name,
- first_name,
- email,
- phone_number,
- hire_date,
- job_id,
- salary,
- commission_pct,
- manager_id,
- department_id);
- END hire_employee;
- -- code for procedure fire_employee
- PROCEDURE fire_employee (emp_id NUMBER)
- IS
- BEGIN
- DELETE FROM employees
- WHERE employee_id = emp_id;
- END fire_employee;
- -- code for function num_above salary
- FUNCTION num_above_salary (emp_id NUMBER)
- RETURN NUMBER
- IS
- emp_sal NUMBER (8, 2);
- num_count NUMBER;
- BEGIN
- SELECT salary
- INTO emp_sal
- FROM employees
- WHERE employee_id = emp_id;
- SELECT COUNT ( * )
- INTO num_count
- FROM employees
- WHERE salary > emp_sal;
- RETURN num_count;
- END num_above_salary;
- END emp_actions;
- /
执行下面语句报错
- CALL emp_actions.hire_employee(300, 'Belden', 'Enrique', 'EBELDEN',
- '555.111.2222', '30-AUG-04', 'AC_MGR', 9000, .1, 101, 110);
ORA-01843 not a valid month
解决:
当我们在一个中文环境的客户端使用如下sql语句,数据库会报告一个ORA-01843的错误,这是因为客户端是中文环境,格式mon就不能用英文的月份写法,必须用中文的“六月”如果不想修改sql语句运行的话,就需要在执行该语句之前,使用alter session 命令将nls_date_language修改为american,如下:
- alter session set nls_date_language='american' --以英语显示日期