Friday, May 15, 2009

Apex runtime maintenance: wwv_flow_api and #IMAGE_PREFIX#

For some reason, the most important API within Apex is not well documented. I was asked to change the image prefix in an Apex environment.

GUI

Using the Graphical User Interface, or GUI, it would have been easy:
  1. On the Workspace home page, click the Application Builder icon.
  2. Select an application.
  3. On the Application home page, click Shared Components.
  4. Under Application, select Definition.
  5. When the Edit Application Definition page appears, locate the Image Prefix field.

However... this was a run-time only install. And much to my astonishment, there is no APEX API to change the image prefix for an application.

wwv_flow_api

After inspection of an Apex application import file, I found the wwv_flow_api procedure is used to create the flow, and define the image prefix (hint: you can change it in the import file, before import). And sure enough, there is a procedure set_image_prefix:
procedure set_image_prefix (
  p_flow_id in number default null,
  p_image_prefix in varchar2 default null)
;

So, basically, you want this:

begin
wwv_flow_api.set_security_group_id(p_security_group_id=>
APEX_UTIL.FIND_SECURITY_GROUP_ID('APP1'));
wwv_flow_api.set_image_prefix(p_image_prefix=>'/i32', p_flow_id=>100);
end;
/

It does no more than update the wwv_flows table, it seems:

SQL> col FLOW_IMAGE_PREFIX for a10
SQL> select id, flow_image_prefix from FLOWS_030100.wwv_flows;

ID FLOW_IMAGE
---------- ----------
100 /i/
4411 /i/
4155 /i/

SQL> begin
2 wwv_flow_api.set_security_group_id(p_security_group_id=>
3 APEX_UTIL.FIND_SECURITY_GROUP_ID('APP1'));
4 wwv_flow_api.set_image_prefix(p_image_prefix=>'/i32/', p_flow_id=>100);
5 end;
6 /

PL/SQL procedure successfully completed.
SQL> select id, flow_image_prefix from FLOWS_030100.wwv_flows;
ID FLOW_IMAGE
---------- ----------
100 /i32/
4411 /i/
4155 /i/

SQL> rollback;

By the way: changing the prefix overall is done by running the reset_image_prefix.sql script, which can be found in the utilities subdirectory of your apex source code.

No comments: