问题
below abstarct type created
create or replace TYPE callbck as table of callback_t;
abstract table
create or replace TYPE CALLBACK_T as object
(
url varchar2(50),
uri_key number,
);
below is the procedure used,
procedure get_callback_info
(
pi_clbk callbck := callbck (),
requestor varchar2,
msg varchar2)
how to pass the parameter for the abstract object type to the procedure get_callback_info.
i have the abstract values 'http://test.com', and 1345 as the url and uri_key
回答1:
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;
/
来源:https://stackoverflow.com/questions/41263056/how-to-pass-object-type-as-a-parameter-in-oracle