Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be55366

Browse files
committed
Inserting only first max display rows
1 parent 9741948 commit be55366

4 files changed

Lines changed: 50 additions & 27 deletions

File tree

source/core/ut_utils.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ create or replace package ut_utils authid definer is
126126
gc_null_string constant varchar2(4) := 'NULL';
127127
gc_empty_string constant varchar2(5) := 'EMPTY';
128128

129+
gc_bc_fetch_limit constant integer := 1000;
130+
gc_diff_max_rows constant integer := 20;
131+
129132
type t_version is record(
130133
major natural,
131134
minor natural,

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,5 +863,14 @@ create or replace package body ut_compound_data_helper is
863863
return l_sql_stmt;
864864
end;
865865

866+
procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw) is
867+
begin
868+
forall idx in 1..a_diff_tab.count
869+
insert into ut3.ut_compound_data_diff_tmp
870+
( diff_id, act_item_data, act_data_id, exp_item_data, exp_data_id, item_no )
871+
values
872+
(a_diff_id, a_diff_tab(idx).act_item_data, a_diff_tab(idx).act_data_id, a_diff_tab(idx).exp_item_data, a_diff_tab(idx).exp_data_id,a_diff_tab(idx).item_no);
873+
end;
874+
866875
end;
867876
/

source/expectations/data_values/ut_compound_data_helper.pks

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ create or replace package ut_compound_data_helper authid definer is
4949

5050
type tt_row_diffs is table of t_row_diffs;
5151

52+
type t_diff_rec is record (
53+
act_item_data clob,
54+
act_data_id raw(32),
55+
exp_item_data clob,
56+
exp_data_id raw(32),
57+
item_no integer
58+
);
59+
type t_diff_tab is table of t_diff_rec;
60+
5261
function get_column_info_xml(a_column_details ut_key_anyval_pair) return xmltype;
5362

5463
function get_columns_filter(
@@ -96,5 +105,8 @@ create or replace package ut_compound_data_helper authid definer is
96105
function generate_join_by_on_stmt (a_column_info xmltype, a_join_by_xpath varchar2) return varchar2;
97106

98107
function generate_join_null_sql (a_column_info xmltype, a_join_by_xpath varchar2) return varchar2;
108+
109+
procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw);
110+
99111
end;
100112
/

source/expectations/data_values/ut_compound_data_value.tpb

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ create or replace type body ut_compound_data_value as
7878

7979
member function get_data_diff(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2,
8080
a_join_by_xpath varchar2, a_unordered boolean) return clob is
81-
c_max_rows constant integer := 20;
81+
c_max_rows integer := ut_utils.gc_diff_max_rows;
8282
l_result clob;
8383
l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab();
8484
l_message varchar2(32767);
@@ -269,27 +269,21 @@ create or replace type body ut_compound_data_value as
269269
l_diff_id ut_compound_data_helper.t_hash;
270270

271271
--Variable for dynamic SQL - to review and simplify ??
272-
l_table_stmt varchar2(32767);
273-
l_where_stmt varchar2(32767);
274-
l_join_by_stmt varchar2(32767);
275-
l_exec_sql varchar2(32767);
276-
l_compare_sql varchar2(32767);
272+
l_table_stmt clob;
273+
l_where_stmt clob;
274+
l_join_by_stmt clob;
275+
l_exec_sql clob;
276+
l_compare_sql clob;
277277

278278
l_other ut_compound_data_value;
279279
l_result integer;
280-
--Max rows to prevent out of memory for too much diffs especially on join by non unique
281-
l_max_rows integer := greatest(self.elements_count,1000);
282-
l_loop_curs sys_refcursor;
283-
type t_diff_rec is record (
284-
act_item_data clob,
285-
act_data_id raw(32),
286-
exp_item_data clob,
287-
exp_data_id raw(32),
288-
item_no integer
289-
);
290-
type t_diff_tab is table of t_diff_rec;
291-
l_diff_tab t_diff_tab;
280+
--We will start with number od differences being displayed.
281+
l_max_rows integer := ut_utils.gc_diff_max_rows;
292282

283+
l_loop_curs sys_refcursor;
284+
l_diff_tab ut_compound_data_helper.t_diff_tab;
285+
l_sql_rowcount integer :=0;
286+
293287
--TEST
294288
t1 pls_integer;
295289

@@ -345,19 +339,24 @@ create or replace type body ut_compound_data_value as
345339
--Pass it to helper as authid as definer
346340
t1 := dbms_utility.get_time;
347341

348-
forall idx in 1..l_diff_tab.count
349-
insert into ut3.ut_compound_data_diff_tmp
350-
( diff_id, act_item_data, act_data_id, exp_item_data, exp_data_id, item_no )
351-
values
352-
(l_diff_id, l_diff_tab(idx).act_item_data, l_diff_tab(idx).act_data_id, l_diff_tab(idx).exp_item_data, l_diff_tab(idx).exp_data_id,l_diff_tab(idx).item_no);
353-
dbms_output.put_line((dbms_utility.get_time - t1)/100 || ' seconds - get col info');
354-
--Exit after first fetch of max rows (to look later)
355-
exit;
342+
if (ut_utils.gc_diff_max_rows > l_sql_rowcount ) then
343+
ut_compound_data_helper.insert_diffs_result(l_diff_tab,l_diff_id);
344+
end if;
345+
346+
l_sql_rowcount := l_sql_rowcount + l_diff_tab.count;
347+
348+
if (ut_utils.gc_diff_max_rows <= l_sql_rowcount and l_max_rows != ut_utils.gc_bc_fetch_limit ) then
349+
l_max_rows := ut_utils.gc_bc_fetch_limit;
350+
end if;
351+
352+
dbms_output.put_line((dbms_utility.get_time - t1)/100 || ' seconds - get col info , values'||l_sql_rowcount);
356353
end loop;
357354

355+
--l_actual.set_difference_count(l_sql_rowcount);
356+
358357
--execute immediate l_exec_sql using l_diff_id, self.data_id,l_actual.data_id;
359358
--result is OK only if both are same
360-
if sql%rowcount = 0 and self.elements_count = l_other.elements_count then
359+
if l_sql_rowcount = 0 and self.elements_count = l_other.elements_count then
361360
l_result := 0;
362361
else
363362
l_result := 1;

0 commit comments

Comments
 (0)