oracle中如何将对象类型作为参数传递 [英] how to pass object type as a parameter in oracle
本文介绍了oracle中如何将对象类型作为参数传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建以下抽象类型
create or replace TYPE callbck as table of callback_t;
抽象表格
create or replace TYPE CALLBACK_T as object
(
url varchar2(50),
uri_key number,
);
以下是使用的程序,
procedure get_callback_info
(
pi_clbk callbck := callbck (),
requestor varchar2,
msg varchar2)
如何将抽象对象类型的参数传递给过程 get_callback_info.
how to pass the parameter for the abstract object type to the procedure get_callback_info.
我有抽象值 'http://test.com',1345 作为 url 和 uri_key
i have the abstract values 'http://test.com', and 1345 as the url and uri_key
推荐答案
假设你有这些类型和程序:
Say you have these types and procedure:
CREATE OR REPLACE TYPE CALLBACK_T AS OBJECT
(
url VARCHAR2(50),
uri_key NUMBER
);
CREATE OR REPLACE TYPE callbck AS TABLE OF callback_t;
CREATE OR REPLACE PROCEDURE get_callback_info(
pi_clbk IN callbck := callbck(),
requestor IN VARCHAR2,
msg OUT VARCHAR2
) IS
BEGIN
/* whatever your code is */
msg := requestor || ' asked information on callbck with ' || pi_clbk.COUNT || ' elements';
END;
您可以使用以下方法测试您的程序:
You can test your procedure with something like:
declare
vCallbck callbck;
vRequestor varchar2(20) := 'a requestor';
vMsg varchar2(100);
begin
/* populate the vCallbck with 10 records */
select CALLBACK_T ('url ' || level, level)
bulk collect into vCallbck
from dual
connect by level <= 10;
--
get_callback_info(vCallbck, vRequestor, vMsg);
--
dbms_output.put_line(vMsg);
end;
/
如果你想用单个值进行测试,可以使用:
If you want to test with a single value, you can use:
declare
vCallbck callbck;
vRequestor varchar2(20);
vMsg varchar2(100);
begin
vCallbck := callbck();
vCallbck.extend(1);
vCallbck(1) := CALLBACK_T('http://test.com', '1345');
--
get_callback_info(vCallbck, vRequestor, vMsg);
--
dbms_output.put_line(vMsg);
end;
/
这篇关于oracle中如何将对象类型作为参数传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文