Hi All,
I have found blob format as file data column in edm_file_storage_tab but I need to get file as respective file format like PDF,docs. Is there any conversion procedure there in IFS?
Hi All,
I have found blob format as file data column in edm_file_storage_tab but I need to get file as respective file format like PDF,docs. Is there any conversion procedure there in IFS?
Best answer by eqbstal
Ok, this is basically a free build of software . Here we go.
Prepare a new directory
This is based upon the network directory:
Notice that it is possible to use a network directory as well. So doesn't have to be on the database server (this would be if you really use a drive letter as in one of my earlier posts.
Below find the total script that you need to run. Notice that in the bottom there are some hardcoded values used with regards to the document number etc.
declare
MyDir_ varchar2(200) := 'MYEQEEP'; -- Same as created one
err_msg_ varchar2(50);
/*******************************************************************************
Description: Copy image of invoice to directory
Date Author Description
-------------------------------------------------------------------------------
26-03-2018 Steve Alink Initial create
*******************************************************************************/
function Cpy_Doc(ora_dir_ in varchar2,
doc_no_ in varchar2, doc_sheet_ in varchar2, doc_rev_ in varchar2,
doc_type_ in varchar2 default 'ORIGINAL', file_no_ in varchar2 default 1, doc_ext_ in varchar2)
return varchar2
is
pdf_file utl_file.file_type;
Stor_buf_ raw(32000);
pdf_blob blob;
pdf_blob_len integer;
vstart number := 1;
addmax binary_integer := 32000;
x number;
l_filename_ varchar2(100);
cursor get_lob is
-- Get LOB locator
select file_data
from ifsapp.edm_file_storage
where doc_no = doc_no_
and doc_sheet = doc_sheet_
and doc_rev = doc_rev_
and doc_type = doc_type_
and file_no = file_no_;
begin
open get_lob;
fetch get_lob into pdf_blob;
close get_lob;
pdf_blob_len := dbms_lob.getlength(pdf_blob);
-- Open the destination files.
l_filename_ := 'NewFile_' || doc_no_ || '.' || doc_ext_;
pdf_file := utl_file.fopen(ora_dir_, l_filename_, 'wb', 32764);
vstart := 1;
-- Save blob length
x := pdf_blob_len;
-- If small enough for a single write
if pdf_blob_len < 32760 then
utl_file.put_raw(pdf_file, pdf_blob);
utl_file.fflush(pdf_file);
else
-- Doesn't fit, have to write it in pieces
vstart := 1;
while vstart < pdf_blob_len and addmax > 0 loop
dbms_lob.read(pdf_blob, addmax, vstart, Stor_buf_);
utl_file.put_raw(pdf_file, Stor_buf_);
utl_file.fflush(pdf_file);
-- Set the start position for the next cut
vstart := vstart + addmax;
-- Set the end position if less than 32000 bytes
x := x - addmax;
if x < 32000 then
addmax := x;
end if;
end loop;
end if;
-- Close the files.
utl_file.fclose(pdf_file);
return 'RANOK';
exception
when others then
-- Close the files if something goes wrong.
if utl_file.is_open(pdf_file) then
utl_file.fclose(pdf_file);
return 'ERROR';
end if;
raise;
end Cpy_Doc;
begin
-- Run the function with some parameter.
err_msg_ := Cpy_Doc(ora_dir_ => MyDir_, doc_no_ => '1202457', doc_sheet_ => '1', doc_rev_ => 'A1', doc_type_ => 'VIEW', file_no_ => 1, doc_ext_ => 'pdf');
end;
Notice that I used doc_type_ VIEW which generates the correct output as well.
I've only tested this with a pdf document that is stored in the database. The result can be found in windows explorer:
Steve
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.