@@ -16,58 +16,70 @@ create or replace type body ut_data_value_anydata as
1616 limitations under the License.
1717 */
1818
19- final member procedure init(self in out nocopy ut_data_value_anydata, a_value anydata, a_data_object_type varchar2, a_extract_path varchar2 ) is
19+ member procedure init(self in out nocopy ut_data_value_anydata, a_value anydata) is
2020 l_query sys_refcursor;
2121 l_ctx number;
2222 l_ut_owner varchar2(250) := ut_utils.ut_owner;
23+ cursor_not_open exception;
24+ l_cursor_number number;
25+ l_type_name varchar2(100);
26+ l_schema varchar(100);
27+ l_part1 varchar(30);
28+ l_part2 varchar(30);
29+ l_dblink varchar(30);
30+ l_part1_type number;
31+ l_objectid number;
2332 begin
24- self.data_type := case when a_value is not null then lower(a_value.gettypename) else 'undefined' end;
33+ self.data_type := case when a_value is not null then lower(a_value.gettypename()) else 'undefined' end;
34+ --TODO : Move that to helper ??
2535 self.data_id := sys_guid();
36+ self.self_type := $$plsql_unit;
37+ self.cursor_details := ut_cursor_details();
2638 if a_value is not null then
39+ dbms_utility.name_resolve(self.data_type,7, l_schema, l_part1, l_part2, l_dblink, l_part1_type, l_objectid);
2740 execute immediate '
2841 declare
2942 l_data '||self.data_type||';
3043 l_value anydata := :a_value;
3144 l_status integer;
45+ l_tmp_refcursor sys_refcursor;
46+ l_refcursor sys_refcursor;
3247 begin
33- l_status := l_value.get'||a_data_object_type ||'(l_data);
48+ l_status := l_value.get'||get_instance(a_value) ||'(l_data);
3449 :l_data_is_null := case when l_data is null then 1 else 0 end;
35- end;' using in a_value, out self.is_data_null;
50+ open l_tmp_refcursor for select l_data '||l_part1||' from dual;
51+ :l_refcursor := l_tmp_refcursor;
52+ end;' using in a_value, out self.is_data_null, out l_query;
53+
3654 else
3755 self.is_data_null := 1;
3856 end if;
39-
4057 ut_compound_data_helper.cleanup_diff;
4158 if not self.is_null() then
42- ut_expectation_processor.set_xml_nls_params();
43- open l_query for select a_value val from dual;
44- l_ctx := sys.dbms_xmlgen.newcontext( l_query );
45- dbms_xmlgen.setrowtag(l_ctx, '');
46- dbms_xmlgen.setrowsettag(l_ctx, '');
47- dbms_xmlgen.setnullhandling(l_ctx,2);
48- execute immediate
49- 'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data) ' ||
50- 'select :self_guid, rownum, value(a) ' ||
51- ' from table( xmlsequence( extract(:l_xml, :xpath ) ) ) a'
52- using in self.data_id, dbms_xmlgen.getXMLtype(l_ctx), a_extract_path;
53- self.elements_count := sql%rowcount;
54- dbms_xmlgen.closecontext (l_ctx);
55- ut_expectation_processor.reset_nls_params();
59+ self.elements_count := 0;
60+ if l_query%isopen then
61+ self.extract_cursor(l_query);
62+ l_cursor_number := dbms_sql.to_cursor_number(l_query);
63+ self.cursor_details := ut_cursor_details(l_cursor_number);
64+ dbms_sql.close_cursor(l_cursor_number);
65+ elsif not l_query%isopen then
66+ raise cursor_not_open;
67+ end if;
5668 end if;
5769 end;
5870
59- static function get_instance(a_data_value anydata) return ut_data_value_anydata is
60- l_result ut_data_value_anydata := ut_data_value_object(null );
71+ member function get_instance(a_data_value anydata) return varchar2 is
72+ l_result varchar2(30 );
6173 l_type anytype;
6274 l_type_code integer;
6375 begin
6476 if a_data_value is not null then
6577 l_type_code := a_data_value.gettype(l_type);
6678 if l_type_code in (dbms_types.typecode_table, dbms_types.typecode_varray, dbms_types.typecode_namedcollection, dbms_types.typecode_object) then
6779 if l_type_code = dbms_types.typecode_object then
68- l_result := ut_data_value_object(a_data_value) ;
80+ l_result := 'object' ;
6981 else
70- l_result := ut_data_value_collection(a_data_value) ;
82+ l_result := 'collection' ;
7183 end if;
7284 else
7385 raise_application_error(-20000, 'Data type '||a_data_value.gettypename||' in ANYDATA is not supported by utPLSQL');
@@ -76,5 +88,28 @@ create or replace type body ut_data_value_anydata as
7688 return l_result;
7789 end;
7890
91+ constructor function ut_data_value_anydata(self in out nocopy ut_data_value_anydata, a_value anydata) return self as result
92+ is
93+ begin
94+ init(a_value);
95+ return;
96+ end;
97+
98+ overriding member function compare_implementation(
99+ a_other ut_data_value,
100+ a_match_options ut_matcher_options,
101+ a_inclusion_compare boolean := false,
102+ a_is_negated boolean := false
103+ ) return integer is
104+ l_result integer := 0;
105+ begin
106+ if not a_other is of (ut_data_value_anydata) then
107+ raise value_error;
108+ end if;
109+
110+ l_result := l_result + (self as ut_data_value_refcursor).compare_implementation(a_other,a_match_options,a_inclusion_compare,a_is_negated);
111+ return l_result;
112+ end;
113+
79114end;
80115/
0 commit comments