Oracle BFILE 操作

 

create procedure set_video(dir_alias varchar2,dept_id number) is
       filename varchar2(40);
       file_ptr BFILE;
       CURSOR emp_csr is
              select first_name from employees
              where department_id = dept_id for update;
begin
  for rec in emp_csr loop
    filename := rec.first_name || '.gif';
    file_ptr := BFILENAME(dir_alias,filename);
    
    update employees 
    set video = file_ptr
    where current of emp_csr;
    
    dbms_output.put_line('file: ' || filename ||' size: '||dbms_lob.getlength(file_ptr));
    dbms_lob.fileclose(file_ptr);
  end loop;
end;

 

posted @ 2013-12-12 10:07  聆听自由  阅读(603)  评论(0编辑  收藏  举报