Downloading documents from Customer table

Hi,
I am getting the following error message, when I execute these codes.  Please advise.
ERROR at line 25: PLS-00103: Encountered the symbol "FILE_NAME" when expecting one of the following:

   . ( ) , * @ % & | = - + < / > at in is mod remainder not
   range rem => ..  <> or != or ~= >= <= <>
   and or like LIKE2_ LIKE4_ LIKEC_ as between from using ||
   multiset member SUBMULTISET_
The symbol "." was substituted for "FILE_NAME" to continue.
1. CREATE OR REPLACE PROCEDURE download_my_file(p_file in number) AS
2. v_mime VARCHAR2(48);
3. v_length NUMBER;
4. v_file_name VARCHAR2(2000);

CREATE OR REPLACE PROCEDURE download_my_file(p_file in number) AS
v_mime VARCHAR2(48);
v_length NUMBER;
v_file_name VARCHAR2(2000);
Lob_loc BLOB;
BEGIN
SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
INTO v_mime,lob_loc,v_file_name,v_length
FROM file_subjects
WHERE id = p_file;
--
-- set up HTTP header
--
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from
windows
owa_util.mime_header( nvl(v_mime,'application/octet'),
FALSE );
-- set the size so the browser knows how much to download
htp.p('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a
save as
htp.p('Content-Disposition: attachment; filename="'||substr(v_
file_name,instr(v_file_name,'/')+1)|| '"');
-- close the headers
owa_util.http_header_close;
-- download the BLOB
wpg_docload.download_file( Lob_loc );
end download_my_file;
/

Open in new window

JohnSrinivassanAsked:
Who is Participating?
 
sdstuberConnect With a Mentor Commented:
looks like your commented lines aren't fully commented...

try this...

CREATE OR REPLACE PROCEDURE download_my_file(p_file IN NUMBER)
AS
    v_mime        VARCHAR2(48);
    v_length      NUMBER;
    v_file_name   VARCHAR2(2000);
    lob_loc       BLOB;
BEGIN
    SELECT mime_type, blob_content, NAME, DBMS_LOB.getlength(blob_content)
      INTO v_mime, lob_loc, v_file_name, v_length
      FROM file_subjects
     WHERE ID = p_file;

--
-- set up HTTP header
--
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
    OWA_UTIL.mime_header(NVL(v_mime, 'application/octet'), FALSE);
-- set the size so the browser knows how much to download
    HTP.p('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
    HTP.p(   'Content-Disposition: attachment; filename="'
          || SUBSTR(v_file_name, INSTR(v_file_name, '/') + 1)
          || '"'
         );
-- close the headers
    OWA_UTIL.http_header_close;
-- download the BLOB
    WPG_DOCLOAD.download_file(lob_loc);
END download_my_file;
/
 

0
 
JohnSrinivassanAuthor Commented:
Stuber,
Thanks for your timely support.  Be in touch.  
0
All Courses

From novice to tech pro — start learning today.