Oracle APEX is just like other development tools, it has development environment and runtime environment. In runtime environment you can not login into the workspace to deploy or modify the application. Normally is this the production environment, because you don’t want any changes to be done in the development environment.
You can install application by running the below script as SYSDBA or APEX_050100 user.
ALTER SESSION SET CURRENT_SCHEMA = APEX_050100;
BEGIN
APEX_INSTANCE_ADMIN.ADD_WORKSPACE ( P_WORKSPACE_ID => null,
P_WORKSPACE => 'LAB',
P_PRIMARY_SCHEMA => 'LABSCH');
END;
/
- Then install the application using the below script. Fist check is the application exists, if yes, deleted it and then install a new version.
spool myapp_install_application.log;
ALTER SESSION SET CURRENT_SCHEMA = APEX_050100;
DECLARE
l_workspace_id NUMBER;
l_app_alias varchar2(100) :='MYAPP';
l_app_schema varchar2(100) :='LABSCH';
-- an application number of an existing application in the workspace.
l_existing_app NUMBER := 5489207;
-- the "new" application number, an existing number will be dropped first.
l_new_app NUMBER := 5489207;
BEGIN
-- set workspace id
SELECT workspace_id INTO l_workspace_id
FROM apex_workspaces
WHERE workspace = 'LAB';
FOR c IN (SELECT app.application_id
FROM apex_applications app
WHERE app.application_id = l_existing_app
)
LOOP
apex_instance_admin.remove_application(l_existing_app);
END LOOP;
-- generate offset for this application
apex_application_install.generate_offset;
-- set application workspace
apex_application_install.set_workspace_id( l_workspace_id );
-- set application ID
apex_application_install.set_application_id(l_new_app);
-- force reset application schema
apex_application_install.set_schema(l_app_schema);
-- Set the application alias
apex_application_install.set_application_alias(l_app_alias);
END;
/
-- Your application as it was exported before.
@f139.sql;
spool off;