Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Import a file into the blob field of oracle

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Create test directories and files on the database host

$mkdir / test

$cd / test

$echo "Test Subject" > > subject.html

$echo "test ok!" > > mail.html

Define the file path (all on the database host) and authorize

$sqlplus user/passwd@instance

SQL > create or replace directory send_file_dir as'/ test'

SQL > grant read on directory send_file_dir to test1

The following is the insert into the emailed table (there are two blob fields subject,message in the table)

$sqlplus user/passwd@instance

SQL > declare

Destloc blob

Destmsg blob

Srcfile bfile:=BFILENAME ('SEND_FILE_DIR','subject.html')

Msgfile bfile:=BFILENAME ('SEND_FILE_DIR','mail.html')

BEGIN

Insert into email_send values (seq_email_id.nextval,null,'test@163.com',null,null,empty_blob (), empty_blob (), sysdate,null,'waiting',0,'HTML',null)

Returning subject,message into destloc,destmsg;-if more than one blob field is added here.

Dbms_lob.fileopen (srcfile)

Dbms_lob.loadfromfile (destloc,srcfile,dbms_lob.getlength (srcfile))

Dbms_lob.fileclose (srcfile)

Dbms_lob.fileopen (msgfile)

Dbms_lob.loadfromfile (destmsg,msgfile,dbms_lob.getlength (msgfile))

Dbms_lob.fileclose (msgfile)

Commit

END

/

This inserts two blob fields into the table email_send.

Subject field content is subject.html

Message field content is mail.html

Error message

ERROR at line 1:

ORA-22288: file or LOB operation FILEOPEN failed

No such file or directory

ORA-06512: at "SYS.DBMS_LOB", line 805

ORA-06512: at line 9

Solution method

These files are on the database host, if there are no these files on the host will report an error. Create directories and files on the host on the ok, I have not found a way to read files remotely, if any brother knows, tell me, thank you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report