【发布时间】:2020-11-04 00:35:44
【问题描述】:
请任何人都可以帮助我。我有一个表格类型对象。
CREATE OR REPLACE TYPE SI_PHONE_ACC_T AS TABLE OF SI_PHONE_ACC;
CREATE OR REPLACE TYPE SI_PHONE_ACC AS OBJECT
(
PHONE_ACC VARCHAR2(15);
);
下面一般是作为UI端的输入传递给过程的。
示例:
SI_PHONE_ACCT_T(SI_PHONE_ACC('123-345-6543'),SI_PHONE_ACC('999-999-9999'), SI_PHONE_ACC('ax878974545787wp')); -- 前 2 位是电话号码,第 3 位是帐号。
电话:
Emp_id--- phone_number
1 -- 123-345-6543
2 -- 999-999-9999
3--- 897-897-8781
帐号表:
Emp_id--- account_number
10 -- A0000
20 -- B0000
30--- ax878974545787wp
CREATE OR REPLACE PACKAGE BODY order_mgr
IS
PROCEDURE ins_trees ( p_emp_details_in IN SI_PHONE_ACC_T )
BEGIN
-- Now, I need to retrieve emp_ids from Phone and Account tables based on the phone or account numbers passed in the input parameter. please let me know how to do this.
---once I get those emp_id's, i need to insert into employee table which contains only one column emp_id.
--Please let me know how to do this.
FOR i IN 1 .. p_emp_details_in.count
LOOP
INSERT into employee (emp_id)
values(??);
END IF;
END LOOP;
END;
【问题讨论】:
-
请告诉我们
describe Phonetable。列 phone_number 真的是 varchar2 吗? -
基本上就是这个例子。但由于 SI_PHONE_ACC_T 类型包含电话和帐户,我只需要 varchar2 的东西。实际的表只包含不同的值与 varchar2。
标签: oracle object stored-procedures input types