Oracle read File from Directory with exception

前端 未结 2 1796
南笙
南笙 2021-01-16 22:57

I\'m reading files from a Directory with the following function:

CREATE OR REPLACE FUNCTION loadBlobFromFile(p_file_name VARCHAR2) RETURN BLOB AS
  dest_loc          


        
2条回答
  •  梦毁少年i
    2021-01-16 23:21

    add an exception like this.

      -- Open temporary lob
      DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
    
      begin
        -- Load binary file into temporary LOB
        DBMS_LOB.LOADFROMFILE(
            dest_lob => dest_loc
          , src_lob  => src_loc
          , amount   => DBMS_LOB.getLength(src_loc));
    
      exception 
        when dbms_lob.operation_failed
        then
          return empty_blob();
      end;
    ..rest of your code.
    

提交回复
热议问题