如何将BLOB_FILE插入到DB Oracle中?

t5fffqht  于 2023-10-16  发布在  Oracle
关注(0)|答案(1)|浏览(134)

如何在PL/SQL中插入BLOB_FILE?
我的尝试:

insert into MY TABLE (SOMETHING,SOMETHING,BLOB_FILE,SOMETHING,SOMETHING,SOMETHING) 
    values(1,'1234HRT',utl_raw.cast_to_raw('path\of\my\file'),7894,SYSDATE,SYSDATE);

有什么建议吗?

des4xlb0

des4xlb01#

你在其他文章中有很多这样的例子。你需要一些pl/sql来将文件发送到blob列:ps:你需要创建一个目录对象来指向文件夹

DECLARE
  src_lob  BFILE := BFILENAME('MY_DIR', '/tmp/me.gif');
  dest_lob BLOB;
BEGIN
  INSERT INTO lob_table VALUES(2, EMPTY_BLOB())
     RETURNING doc INTO dest_lob;

  DBMS_LOB.OPEN(src_lob, DBMS_LOB.LOB_READONLY);
  DBMS_LOB.LoadFromFile( DEST_LOB => dest_lob,
                         SRC_LOB  => src_lob,
                         AMOUNT   => DBMS_LOB.GETLENGTH(src_lob) );
  DBMS_LOB.CLOSE(src_lob);

  COMMIT;
END;

相关问题