Saturday, November 25, 2006

 

Upload table structure and download procedure

Upload table should have this structure:
create table Documents(
NAME VARCHAR2(256) not null,
MIME_TYPE VARCHAR2(128),
DOC_SIZE NUMBER,
DAD_CHARSET VARCHAR2(128),
LAST_UPDATED DATE,
CONTENT_TYPE VARCHAR2(128),
BLOB_CONTENT BLOB,
// your additional columns
)
The name must be unique.

Download procedure:

procedure documentdownload is
v_filename Documents.name%type;
function getfilepath return varchar2 is
script_name varchar2(255) default owa_util.get_cgi_env( 'SCRIPT_NAME' );
path_info varchar2(255) default owa_util.get_cgi_env( 'PATH_INFO' );
pos number;
x varchar2(50) := 'docs'; --variable from PlsqlDocumentPath
begin
script_name := script_name path_info;
pos := instr(script_name, x);
script_name := substr(script_name, pos+length(x)+1, length(script_name)-pos-length(x));
return script_name;
end getfilepath;
begin
v_filename := upper(getfilepath);
select name into v_filename
from Documents
where UPPER(name) = v_filename;
wpg_docload.download_file(v_filename);
end;

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?