Skip to main content

Posts

Showing posts with the label APEX

How to return json with null value using apex_json.write(ref_cursor)

Few days ago I had to develop dynamic query json export module. As a sandbox I prepared PLSQL block: DECLARE c sys_refcursor; l_sql varchar2(4000) := 'select null as "col1", 100 as "col2" from dual union all select 200 as "col1", null as "col2" from dual'; l_file clob; BEGIN open c for l_sql; apex_json.initialize_clob_output; apex_json.open_object; apex_json.write('rowset', c); apex_json.close_object; l_file := apex_json.get_clob_output; apex_json.free_output; DBMS_OUTPUT.PUT_line(l_file); END; { "rowset": [{ "col2": 100 }, { "col1": 200 } ] } As you can see above PLSQL code doesn't return null value pairs : ( apex_json.write(p_name IN VARCHAR2, p_cursor IN OUT NOCOPY sys_refcursor) procedure Signature 14 doesn't support null. How to fix it... ? APEX API provides apex_js...

New plugins to store files outside your database!

The plugins we release helps you easly upload files to Amazon AWS S3. Below we have simple installation tutorial and for more you can always visit our DEMO application. Actually, this plugin is in 2 parts: - "FMcomponent" part is APEX item. Something like native filebrowser item but fully configurable. You can always customize how it with a sparkle of CSS. - "FMproviders" part serves as connection to one of the file storage service (eg. Amazon S3, Dropbox, etc) To use it, you have to grand DBMS_CRYPTO privilege to your Oracle schema: grant execute on sys.dbms_crypto to <schema>; Next, install both plugins into your APEX application: FMcomponent and specific FMprovider (currently we provide AWS S3 FMprovider). At the end you have to install additional  package . As a schema owner open your favorite SQL editor and run as first apexutil_fm_aws.pls and second apexutil_fm_aws.plb. Now you can try to add plugins in your application. Go to Apex Ap...

Make your Automatic Time Zone pretty

While the automatic time zone works, it looks bad. Often when the main page is heavy user needs to look on the white page for a while. APEX doesn't let you change this page natively. I have a nice MIP (Make It Pretty) for you. Check the results: Try our sandbox demo to see the result! Steps to implement the solution: 1) In "Application -> Shared Components -> Application Processes" create a process "On Load: Before Header" with this PL/SQL: declare v_timezone varchar2(4000) := apex_util.get_session_time_zone(); begin -- if no timezone then go to error message if( v_timezone is null ) then raise_application_error(-20001, 'Get timezone'); end if; end; 2) Add this HTML to "Process Error Message" <!-- All we do is in this container will be moved at the top of the page when page loads --> <div id="timezone-window-div"> <!-- I would suggest using JQUERY stored on your side, not from googl...

SQL query result as JavaScript array

Today there was a need of using simple, dictionary SQL query result as an array in JavaScript. Solution is quite simple - region with PL/SQL Dynamic Content. Here you have a short video with example. Changing Select List causes showing Checkboxes in rows, on which specific action can be processed. Code of PL/SQL region, which creates array: htp.p('<script>'); htp.p('var actions = [];'); for x in (select ID, STATUS_FROM from ACTIONS ) loop htp.p('actions[' || x.id || '] = "' || x.status_from || '";'); end loop; htp.p('</script>'); JavaScript code for Dynamic Action, which uses the array: $("input[name='f02']").each(function(){ if (this.getAttribute("status") == actions[$v("P18_ACTION")]) { this.style.display = "block"; } else { this.style.display = "none"; } });