Add the download hyperlink operation method to Oracle Report

  • 2020-12-05 17:25:45
  • OfStack

1. Add a text box in the corresponding position of the layout of the report page, generally Download
Right-click the PL/SQL editor to make a hyperlink and add the following:
 
function B_13FormatTrigger return boolean is 
begin 
IF upper(:P_ACTION) != 'DOWNLOAD' THEN 
return (FALSE); 
ELSE 
srw.set_hyperlink(EXP_FILE.linkto); 
return (TRUE); 
END IF; 
end; 

2. Set up program units EXP_FILE and EXP_FILE, and add link_to function, which is as follows:
 
FUNCTION linkto RETURN VARCHAR2 
IS 
BEGIN 
RETURN (:P_URL||filename); 
END linkto; 

3. Write trigger BEFORE_REPORT to append the content to download to the download page. The content is as follows:
 
function BeforeReport return boolean is 
begin 
If upper(:P_ACTION) = 'DOWNLOAD' then 
:P_SESSION := USERENV('SESSIONID'); 
:P_TEST := EXP_FILE.make('Vendor_Item_Reference_Enquiry_'||to_char(sysdate,'yyyymmddhh24miss'),:P_USERID,'csv',false); 
EXP_FILE.append('|'||'|'||'|'||'|'||'Vendor Item Reference Enquiry'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'); 
EXP_FILE.append('|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'); 
EXP_FILE.append('Selection criteria'||'|'||'CCN:'||'|'||:P_CCN||'|'||'|'||'Mas Loc:'||'|'||:P_MASLOC||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'); 
EXP_FILE.append('|'||'Division:'||'|'||:P_FR_DIV||'|'||'|'||'To:'||'|'||:P_TO_DIV||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'); 
EXP_FILE.append('|'||'|'||'Vendor:'||'|'||:P_FR_VENDOR||'|'||'|'||'To:'||'|'||:P_TO_VENDOR||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'); 
EXP_FILE.append('|'||'|'||'Item:'||'|'||:P_FR_ITEM||'|'||'|'||'To:'||'|'||:P_TO_ITEM||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'||'|'); 
EXP_FILE.append('Dept*'|| '|' ||'Vendor'||'|'||'Pur Loc '||'|'||'Item'||'|'||'Make'||'|'||'Description'||'|'||'Env. Std.'||'|'||'Env. Status '); 
return(true); 
else 
return(true); 
end if; 
end; 

Related articles: