create or replace procedure bcd_ict_dms_load_file(p_file_name in bcd_ict_bcd_dms.bibd_document%Type) as

    v_bfile bfile;
    v_blob blob;

begin

    insert into bcd_ict_bcd_dms(

    bibd_Business_unit,
    bibd_Department,
    bibd_doc_type,
    bibd_doc_class,
    bibd_doc_name,
    bibd_upload_date,
    bibd_uploaded_by,
    bibd_document)

    Values
    (
    'LEISURE',
    'AP',
    'SUPPLIER_INVOICE',
    'PDF',
    p_file_name,
    TO_DATE(SYSDATE),
    'SP',
    EMPTY_BLOB()
    )
    return bibd_document into v_blob;
    
    v_bfile:=Bfilename('bcd_dms_leisure',p_file_name);
    
    dbms_lob.fileopen(v_bfile,dbms_lob.File_Readonly);
    dbms_lob.loadfromfile(v_blob, v_bfile,dbms_lob.getlength(v_bfile));
    dbms_lob.fileclose(v_bfile);
     
    commit;

end;
