Displaying Images in Oracle Apex
Displaying Images in Oracle Apex
Steps :
1. Create PL/SQL dynamic Content Region and write the code
declarecursor c1 isselect FILE_SHORT_INFO,emp_code from prtl_files where emp_code = :P8_empcd;t varchar2(200);beginfor i in c1loophtp.p('<body>');htp.p('<p> </p>');htp.p('<table width="100%">');htp.p('<tr>');
for rec in (select * from PRTL_FILES
where emp_code = :P8_EMPCD and status='A')loopIF rec.ATT_MIMETYPE is not null or rec.ATT_MIMETYPE != '' THENhtp.p('<td colspan="2">'); htp.p( '<img src="my_image_display? fid='||NVL(rec.FILE_ID,0)||'" height="'||100||'"/>' );
htp.p('</td>');
elsehtp.p('<td colspan="2">'); htp.p( 'No Image ');
htp.p('</td>');
END IF;end loop;beginselect pos_owner ||' ['||pos_name||']' into t from prtl_pos
where emp_code = :P8_empcd;exceptionwhen no_data_found then t:='N/A';end;htp.p('<br>');htp.p('<b>'); htp.p(t); htp.p('</b>');htp.p('</tr>');htp.p('<tr>');htp.p('<td colspan="2">'); htp.p(i.FILE_SHORT_INFO);
htp.p('<p> </p>');htp.p('<p> </td>');htp.p('</tr>');htp.p('</table>');htp.p('</body>');htp.p('</html>');end loop;end;
Note : I wrote this code as per my requirement. You need to change the code as per your requirement.
2. My_Image_Display Procedure
create or replace procedure my_image_display (fid in number)asl_mime varchar2 (255);l_length number;lob_loc blob;l_file_name VARCHAR2 (2000);begin-- http://blog.hilandco.com/2010/05/how-to-show-blob-type-column-as-image.htmlselect ATT_MIMETYPE, ATTACHMENT, dbms_lob.getlength (ATTACHMENT)into l_mime, lob_loc, l_lengthfrom PRTL_FILESwhere file_id = fid;OWA_UTIL.mime_header (NVL (l_mime, 'application/octet'), FALSE);HTP.p ('Content-length: ' || l_length);OWA_UTIL.http_header_close;WPG_DOCLOAD.download_file (lob_loc);end;
reference :
Comments
Post a Comment