Adapun hal yang harus diperhatikan pada bagian
- Package/procedure
- Contoh
- Tambahkan nvl(lob_column, empty_blob())
- Gunakan htp.p
- Untuk kasus image jika ingin tampil inline, lakukan comment pada bagian
- Security
- Anda harus tahu environment server apa yang dipakai, apakah EPG, OHS atau APEX Listener
- Untuk APEX Listener/OHS anda cukup grant APEX_PUBLIC_USER
- Untuk OHS grant APEX_PUBLIC_USER dan daftarkan procedure yang akan dipanggil di APEX_XXXXXX.wwv_flow_epg_include_mod_local
- Untuk EPG anda grant ke ANONYMOUS dan aktifkan procedure di APEX_XXXXXX.wwv_flow_epg_include_mod_local
- Cara memanggil dengan signature parameter.
- mulai dengan ? pisahkan dengan &
- Posisi tidak penting namun harus disebutkan semua kecuali punya default value
- Untuk kasus APEX listener parameter signature akan selalu dirubah dengan menjadi lowercase, hati-hati jika memakai parameter non-case-sensitive seperti BI Publisher web service
- contoh
- contoh array parameter
create or replace PACKAGE BODY web_utils IS
-- retrieves image from blob in product info
PROCEDURE display_bu_logo (p_id number, p_product_name varchar2)
IS
l_mime varchar2 (255);
l_length number;
l_file_name varchar2 (2000);
lob_loc blob;
begin
if p_id is not null then
select mimetype
, filename
, nvl(product_image, empty_blob()) blob_content
, dbms_lob.getlength(product_image)
into l_mime
, l_file_name
, lob_loc
, l_length
from demo_product_info
where product_id = p_id;
elsif p_product_name is not null then
select mimetype
, filename
, nvl(product_image, empty_blob()) blob_content
, dbms_lob.getlength(product_image)
into l_mime
, l_file_name
, lob_loc
, l_length
from demo_product_info
where lower(product_name) = lower(p_product_name);
end if;
owa_util.mime_header (nvl (l_mime, 'application/octet'), false);
-- set the size so the browser knows how much to download
htp.p ('Content-length: ' || l_length);
-- the filename will be used by the browser if the users does a save as
htp.p ( 'Content-Disposition: attachment; filename="'
|| replace (replace (substr (l_file_name,
instr (l_file_name, '/') + 1
),
chr (10),
null
),
chr (13),
null
)
|| '"'
);
-- close the headers
owa_util.http_header_close;
-- download the BLOB
wpg_docload.download_file (lob_loc);
END display_bu_logo;
END web_utils;
-- htp.p ( 'Content-Disposition: attachment; filename="' -- || replace (replace (substr (l_file_name, -- instr (l_file_name, '/') + 1 -- ), -- chr (10), -- null -- ), -- chr (13), -- null -- ) -- || '"' -- );
http://localhost:8888/ords/hr.web_utils.display_bu_logo?p_product_name=Blouse&p_id=
http://localhost:8888/ords/!hr.web_utils.display_bu_logo?p_product_name=Blouse&p_id=
- APEX Listener / ORDS 2.0.8.163.10.40
Tidak ada komentar :
Posting Komentar