Posts

Showing posts from August, 2014

Getting the instance URL

To get the instance URL of your APEX environment, it is not too uncommon to use OWA_UTIL.GET_CGI_ENV function calls, similar to the below block: declare l_protocol varchar2(5); l_host varchar2(150); l_script varchar2(15); l_instance_url varchar2(200); begin l_protocol := owa_util.get_cgi_env('REQUEST_PROTOCOL'); l_host := owa_util.get_cgi_env('HTTP_HOST'); l_script := owa_util.get_cgi_env('SCRIPT_NAME'); l_instance_url := l_protocol; l_instance_url := l_instance_url || '://'; l_instance_url := l_instance_url || l_host; l_instance_url := l_instance_url || l_script; l_instance_url := l_instance_url || '/'; dbms_output.put_line(l_instance_url); end; Something you might not know, is that there are a couple of helper functions in the APEX API that allow you to do exactly that. Option 1: APEX_UTIL.HOST_URL('SCRIPT') Reference:  http://docs.orac

APEX5 EA APEX_ZIP usage

I recently saw a link to a presentation that made mention of APEX_ZIP for the upcoming release of APEX (Version 5). Currently in early adopter, you can have a play around. So just thought I'd go and have a bit more of a play to see the possiblities. On the presentation, and specifically for extracting files the sample code is: declare l_zip_file BLOB; l_unzipped_file BLOB; l_files apex_zip.t_files; begin select file_content into l_zip_file from my_zip_files where file_name = :P13_file_name; l_files := apex_zip.get_files(p_zipped_blob => l_zip_file); for i in 1..l_files.COUNT LOOP l_unzipped_file := apex_zip.get_file_content(p_zipped_blob => l_zip_file, p_file_name => l_files(i)); insert into my_files (file_name, file_content) values (l_files(i), l_unzipped_file)