/
substr.plsql
52 lines (33 loc) · 1.21 KB
/
substr.plsql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
create directory blob_substr_dir as 'c:\temp';
$del c:\temp\substr_de123_expected.txt
$del c:\temp\substr_de123_gotten.txt
$del c:\temp\substr_234_expected.txt
$del c:\temp\substr_234_gotten.txt
$del c:\temp\substr_bcde12345AB_expected.txt
$del c:\temp\substr_bcde12345AB_gotten.txt
declare
b blob;
procedure t(b_ in blob, length_ in number, start_ in number, filename in varchar2) is -- {
b_expected blob;
b_gotten blob;
begin
b_expected := dbms_lob .substr(b_, length_, start_);
b_gotten := blob_wrapper.substr(b_, length_, start_, chunk_size => 5);
blob_wrapper.to_file('BLOB_SUBSTR_DIR', 'substr_' || filename || '_expected.txt', b_expected);
blob_wrapper.to_file('BLOB_SUBSTR_DIR', 'substr_' || filename || '_gotten.txt' , b_gotten );
dbms_lob.freeTemporary(b_gotten);
end t; -- }
begin
b := utl_raw.cast_to_raw('abcde12345ABCDE');
t(b, 5, 3, 'de123');
t(b, 3, 7, '234');
t(b, 11, 2, 'bcde12345AB');
end;
/
drop directory blob_substr_dir;
$ c:\temp\substr_de123_expected.txt
$ c:\temp\substr_de123_gotten.txt
$ c:\temp\substr_234_expected.txt
$ c:\temp\substr_234_gotten.txt
$ c:\temp\substr_bcde12345AB_expected.txt
$ c:\temp\substr_bcde12345AB_gotten.txt