SQL>
SQL> CREATE OR REPLACE DIRECTORY books_Dir AS 'C:\BOOKS';
Directory created.
SQL>
SQL> DECLARE
2 v_FILE1 BFILE;
3 v_FILE2 BFILE;
4 v_FILE3 BFILE;
5 v_GETLENGTH1 INTEGER;
6 v_GETLENGTH2 INTEGER;
7 v_GETLENGTH3 INTEGER;
8 v_COMPARELENGTH INTEGER;
9 v_COMPARERESULT INTEGER;
10
11 BEGIN
12 v_FILE1 := BFILENAME('BOOKS_DIR','1.GIF');
13 v_FILE2 := BFILENAME('BOOKS_DIR','2.GIF');
14 v_FILE3 := BFILENAME('BOOKS_DIR','5.GIF');
15
16 DBMS_LOB.FILEOPEN(v_FILE1);
17 DBMS_LOB.FILEOPEN(v_FILE2);
18 DBMS_LOB.FILEOPEN(v_FILE3);
19
20 v_GETLENGTH1 := DBMS_LOB.GETLENGTH(v_FILE1);
21 v_GETLENGTH2 := DBMS_LOB.GETLENGTH(v_FILE2);
22 v_GETLENGTH3 := DBMS_LOB.GETLENGTH(v_FILE3);
23
24 IF v_GETLENGTH1 < v_GETLENGTH2 THEN
25 v_COMPARELENGTH := v_GETLENGTH1;
26 ELSE
27 v_COMPARELENGTH := v_GETLENGTH2;
28 END IF;
29
30 v_COMPARERESULT := DBMS_LOB.COMPARE(v_FILE1,v_FILE2,v_COMPARELENGTH,1,1);
31
32 IF v_COMPARERESULT = 0 THEN
33 DBMS_OUTPUT.PUT_LINE('Both Files Are Identical');
34 ELSE
35 DBMS_OUTPUT.PUT_LINE('Both Files Are Different');
36 END IF;
37
38 IF v_GETLENGTH1 < v_GETLENGTH3 THEN
39 v_COMPARELENGTH := v_GETLENGTH1;
40 ELSE
41 v_COMPARELENGTH := v_GETLENGTH3;
42 END IF;
43
44 v_COMPARERESULT := DBMS_LOB.COMPARE(v_FILE1,v_FILE3,v_COMPARELENGTH,1,1);
45
46 IF v_COMPARERESULT = 0 THEN
47 DBMS_OUTPUT.PUT_LINE('Both Files Are Identical');
48 ELSE
49 DBMS_OUTPUT.PUT_LINE('Both Files Are Different');
50 END IF;
51
52 DBMS_LOB.FILECLOSEALL;
53 END;
54 /
DECLARE
*
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
The system cannot find the path specified.
ORA-06512: at "SYS.DBMS_LOB", line 523
ORA-06512: at line 16
SQL> --