Under the internal user, the authorization of the scott user is as follows:
SQL> conn internal
Please enter password: *******
Connected.
SQL>grant create any directory to scott;
SQL>grant create any library to scott;
Execute the following statement under the user scott:
SQL> conn scott/tiger;
Connected.
SQL>create table bfile_tab (bfile_column BFILE);
SQL>create table utl_lob_test (blob_column BLOB);
SQL>create or replace directory utllobdir as 'd:/temp';
SQL>set serveroutput on
Then execute the following statement and store the word file in the d:/temp directory into utl_lob_test
The blob_column field in the table is in.
declare
a_blob BLOB;
a_bfile BFILE := BFILENAME('UTLLOBDIR',''); -- Used to point to external operating system files
begin
insert into bfile_tab values (a_bfile)
returning bfile_column into a_bfile;
insert into utl_lob_test values (empty_blob())
returning blob_column into a_blob;
dbms_lob.fileopen(a_bfile);
dbms_lob.loadfromfile(a_blob, a_bfile, dbms_lob.getlength(a_bfile));
dbms_lob.fileclose(a_bfile);
commit;
end;
/
SQL>show errors
At this time, you can use the getlength procedure of the DBMS_LOB package to detect whether the word file has been stored in
It's in the blob field. like:
SQL> select dbms_lob.getlength(blob_column) from UTL_LOB_TEST;
The results are as follows:
DBMS_LOB.GETLENGTH(BLOB_COLUMN)
-------------------------------
83968
This means that the word file has been saved in the blob field.
SQL> conn internal
Please enter password: *******
Connected.
SQL>grant create any directory to scott;
SQL>grant create any library to scott;
Execute the following statement under the user scott:
SQL> conn scott/tiger;
Connected.
SQL>create table bfile_tab (bfile_column BFILE);
SQL>create table utl_lob_test (blob_column BLOB);
SQL>create or replace directory utllobdir as 'd:/temp';
SQL>set serveroutput on
Then execute the following statement and store the word file in the d:/temp directory into utl_lob_test
The blob_column field in the table is in.
declare
a_blob BLOB;
a_bfile BFILE := BFILENAME('UTLLOBDIR',''); -- Used to point to external operating system files
begin
insert into bfile_tab values (a_bfile)
returning bfile_column into a_bfile;
insert into utl_lob_test values (empty_blob())
returning blob_column into a_blob;
dbms_lob.fileopen(a_bfile);
dbms_lob.loadfromfile(a_blob, a_bfile, dbms_lob.getlength(a_bfile));
dbms_lob.fileclose(a_bfile);
commit;
end;
/
SQL>show errors
At this time, you can use the getlength procedure of the DBMS_LOB package to detect whether the word file has been stored in
It's in the blob field. like:
SQL> select dbms_lob.getlength(blob_column) from UTL_LOB_TEST;
The results are as follows:
DBMS_LOB.GETLENGTH(BLOB_COLUMN)
-------------------------------
83968
This means that the word file has been saved in the blob field.