|
| 1 | +PROMPT ut_output_dbms_output.send_clob Sends a clob Into Pipe in a separate session and recieves it back cut into 4000 char pieces |
| 2 | + |
| 3 | +declare |
| 4 | + l_message_lenght integer := 98765; |
| 5 | + l_output ut_output_dbms_output := ut_output_dbms_output(); |
| 6 | + l_text_lenght integer; |
| 7 | + l_chunk_lenght integer; |
| 8 | +begin |
| 9 | + --Arrange - send clob to dbms_output |
| 10 | + declare |
| 11 | + l_expected_length integer := l_message_lenght; |
| 12 | + l_max_varchar2_len integer := 32767; |
| 13 | + l_loops integer := floor(l_expected_length / l_max_varchar2_len); |
| 14 | + l_string varchar2(32767); |
| 15 | + l_output ut_output_dbms_output := ut_output_dbms_output(); |
| 16 | + l_lob clob; |
| 17 | + begin |
| 18 | + dbms_lob.createtemporary(l_lob, true); |
| 19 | + for i in 1 .. l_loops loop |
| 20 | + l_string := lpad('a', l_max_varchar2_len, 'a'); |
| 21 | + dbms_lob.writeappend( l_lob, length(l_string), l_string ); |
| 22 | + end loop; |
| 23 | + if l_loops*l_max_varchar2_len < l_expected_length then |
| 24 | + l_string := lpad('a', mod(l_expected_length, l_max_varchar2_len), 'a'); |
| 25 | + dbms_lob.writeappend( l_lob, length(l_string), l_string ); |
| 26 | + end if; |
| 27 | + l_output.send_clob(l_lob); |
| 28 | + end; |
| 29 | + |
| 30 | + |
| 31 | + --Act - get clob as lines from dbms_output |
| 32 | + select sum(nvl(length(column_value),0)), max(length(column_value)) |
| 33 | + into l_text_lenght, l_chunk_lenght |
| 34 | + from table( l_output.get_lines(NULL) ); |
| 35 | + --Assert - check that the length of text recieved is same as lenght of text sent |
| 36 | + if l_text_lenght = l_message_lenght and l_chunk_lenght = 4000 then |
| 37 | + :test_result := ut_utils.tr_success; |
| 38 | + elsif not nvl(l_chunk_lenght,0) = 4000 then |
| 39 | + dbms_output.put_line('Expected chunk length of 4000 but got'||l_chunk_lenght); |
| 40 | + else |
| 41 | + dbms_output.put_line('Expected '||l_message_lenght||' characters, got '||l_text_lenght); |
| 42 | + end if; |
| 43 | +end; |
| 44 | +/ |
| 45 | + |
| 46 | + |
| 47 | + |
0 commit comments