这是我的包裹:
CREATE OR REPLACE PACKAGE DEPARTMENT_INFO AS
TYPE t_dep_loc IS RECORD(region_name regions.region_name%type,
country_name countries.country_name%type,
state locations.state_province%type,
city locations.city%type);
TYPE t_dep_mgr IS RECORD(first_name employees.first_name%type,
last_name employees.last_name%type,
email employees.email%type,
phone_number employees.phone_number%type);
FUNCTION location_department(p_department_id departments.department_id%TYPE)
RETURN t_dep_loc;
FUNCTION manager_department(p_department_id departments.department_id%TYPE)
RETURN t_dep_mgr;
END DEPARTMENT_INFO;
CREATE OR REPLACE PACKAGE BODY department_info AS
FUNCTION location_department(p_department_id departments.department_id%TYPE)
RETURN t_dep_loc
AS
v_dep_loc t_dep_loc;
begin
select r.region_name, co.country_name, l.state_province, l.city
into v_dep_loc.region_name, v_dep_loc.country_name, v_dep_loc.state, v_dep_loc.city
from regions r
join countries co on r.region_id = co.region_id
join locations l on l.country_id = co.country_id
join departments d on l.location_id = d.location_id
where d.department_id = p_department_id;
return v_dep_loc;
end;
FUNCTION manager_department(p_department_id departments.department_id%TYPE)
RETURN t_dep_mgr
AS
v_dep_mgr t_dep_mgr;
begin
select e.first_name, e.last_name, e.email, e.phone_number
into v_dep_mgr.first_name, v_dep_mgr.last_name, v_dep_mgr.email, v_dep_mgr.phone_number
from employees e
join departments d on e.employee_id = d.manager_id
where d.department_id = p_department_id;
return v_dep_mgr;
end;
END;
我尝试使用/
来标记PL / SQL块的结尾,但后来我得到了相同的错误,但不是来自CREATE,而是来自/
。
这是错误:
Error(18,1): PLS-00103: Encountered the symbol "CREATE"
这是我第一次使用该程序而我正在使用示例解决方案。
答案 0 :(得分:3)
不要忘记在脚本之间加入/
CREATE OR REPLACE
PACKAGE DEPARTMENT_INFO AS
end DEPARTMENT_INFO;
/ <--- use this one after package script and before package body script
CREATE OR REPLACE
PACKAGE BODY DEPARTMENT_INFO AS
end DEPARTMENT_INFO;
如果您要同时编译这两个脚本,请在第一个脚本的末尾加上/
或逐个编译它们。