【发布时间】:2020-01-20 14:22:32
【问题描述】:
我需要在存储过程中检查输入参数中的值是否为 NULL 或 NOT。输入参数是表格类型,其中包含嵌套对象。它包含 3 个属性 - 员工 ID、经理 ID 和地址。我需要检查 manager_id 和 employee_id 是否为 NULL。根据值是否为 NULL,我需要插入两个不同的表。
CREATE OR REPLACE PACKAGE BODY order_mgr
IS
PROCEDURE ins_trees ( p_emp_details_in IN trees_type_t,
p_nrmployee_Id IN NUMBER
)
BEGIN
-- Condition goes here.. please let me know how to check this in the table type object as it contains nested object.
-- IF the manager_id is NULL in the trees_type_t type object
THEN
INSERT into emp (employee_id, address)
values(p_emp_details_in.employee_id, p_emp_details_in.address_id);
END IF;
-- Condition goes here.. please let me know how to check this in the table type object as it contains nested object.
-- IF the (employee_id is NULL in the trees_type_t type object then
INSERT into manager (manager_id, address)
values(p_emp_details_in.manager_id,p_emp_details_in.address_id);
END IF;
END;
END;
/
对象类型:
create or replace TYPE trees_type_t AS TABLE OF tree_obj_type;
create or replace TYPE tree_obj_type AS OBJECT
(
employee_id VARCHAR2(10),
manager_id VARCHAR2(10),
address VARCHAR2(100),
);
请建议并帮助我。
【问题讨论】:
-
您的代码将不起作用。 p_emp_details_in 是一个集合。您必须对其进行迭代以获取每个对象值。
标签: oracle object stored-procedures input types