Hi, guys:
I have one question regarding loading images:
I need to write a procedure so our APEX application can display multiple images of same person stored in database. current system use html expression to display only one picture per person.
<img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">
and current system use the following stored procedure
create or replace
procedure dl_sor_image (p_offender_id IN NUMBER) as
v_mime_type VARCHAR2(48);
v_length NUMBER;
v_name VARCHAR2(2000);
v_image BLOB;
BEGIN
SELECT 'IMAGE/JPEG', dbms_lob.getlength(image), image
INTO v_mime_type, v_length, v_image
FROM sor_image
WHERE offender_id = p_offender_id
and image_id = (select max (image_id) from sor_image where offender_id = p_offender_id);
-- setup the HTTP headers
owa_util.mime_header(nvl(v_mime_type, 'application/octet'), FALSE);
htp.p('Content-length: '||v_length);
--htp.p('Content-Disposition: attachment; filename="' || substr(v_name, instr(v_name,'/') + 1) || '"');
--htp.p('Content-Disposition: attachment; filename="'somemmmmmfilename.jpg'");
-- close the headers
owa_util.http_header_close;
-- download the Photo blob
wpg_docload.download_file (v_image);
END dl_sor_image;
I replace the procedure and html expression as follows to see if APEX can show the second image.
<img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75">
create or replace
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
v_mime_type VARCHAR2(48);
v_length NUMBER;
v_name VARCHAR2(2000);
v_image BLOB;
v_counter number:=0;
cursor cur_All_Images_of_Offender is
SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
FROM sor_image
WHERE offender_id = p_n_Offender_id;
rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
BEGIN
open cur_All_Images_of_Offender;
loop
fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
v_counter:=v_counter+1;
if (v_counter=p_n_image_Count) then
owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
htp.p('Content-length: '||rec_Image_of_Offender.image_length);
owa_util.http_header_close;
wpg_docload.download_file (rec_Image_of_Offender.image);
end if;
exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
end loop;
close cur_All_Images_of_Offender;
END Sor_Display_Current_Image;
However, it looks APEX only binds the "DL_SOR_IMAGE" procedure in the html expression. If I change the procedure name, APEX won't use it and show image, even I tried to copy the exactly same code from "DL_SOR_IMAGE" procedure. I also notice that if I change code inside "DL_SOR_IMAGE" procedure, it can display the the specific image, as long as I use existing procedure specification. But I want to use multiple parameters. So I suspect it is something related to APEX configuration such as make file in other IDE. I do not think it is the problem of code, it is because APEX cannot use any new procedure in the HTML expression.Could anyone give me a hint on this?