rem This assumes that the original and target workspaces both have the same names
SET WORKSPACE=MYWORKSPACE
rem A list of all the Apex application numbers
SET APPLIST=200,201,202
rem Java host connect string - eg OracleDeveServer1:1521:dev1
SET JAVA_CONNECT=OracleHostname:PortNumber:Servicename
rem Logon information
SET JAVA_USER=myoracleusername
rem Or provide the password as a parameter to the batch file if there are security issues
rem about hard-coding it
SET JAVA_PASSWORD=myoraclepassword
SET SQLPLUS_LOGON=%JAVA_USER%/%JAVA_PASSWORD%
rem File names and paths.
rem Temporary script file
SET PACKAGES_DUMPSCRIPT=PACKAGE_DUMP.SQL
rem Name of stylesheet
SET STYLESHEET_NAME=mystylesheet.css
rem Path on target server into which the output scripts should be copied
SET TARGETPATH=\\mytargetserver\c$\incoming\scripts\
rem This is the physical path to which Oracle writes its output file
SET OUTPATH=d:\export\code\
rem Path to stylesheet on originating server
SET STYLESHEET_FROM_PATH=d:\oracle\product\10.2.0\http_1\apeximages\images\themes\theme_999\
rem Path to stylesheet on target server
SET STYLESHEET_TO_PATH=\\mytargetserver\c$\oracle\product\10.2.0\http_1\apeximages\images\themes\theme_999\
rem On Windows java requires the CLASSPATH to point to both the path to the Oracle Java
rem libraries and the path to oracle.apex.APEXExport
SET CLASSPATH=d:\downloads\oracle\apex_3.1\apex\utilities;d:\oracle\product\10.2.0\db_1\jdbc\lib\classes12.jar
rem This will be appended to scripts copied to the target server (in this case it's the staging server)
SET TARGETSUFFIX=_stage
rem The version of the copied application is supplied as the first parameter
SET VERSION=%1
rem Set DATE_TIME to a unique string
call :SETDATETIME DATE_TIME
rem Set the name of the outuput file to hold all the PL/SQL code. If package export
rem only, use DATE_TIME
IF *%1==*PACK_ONLY SET PACKAGES_OUTFILE=ALL_PACKAGES_%DATE_TIME%.SQL
IF NOT *%1==*PACK_ONLY SET PACKAGES_OUTFILE=ALL_PACKAGES_%VERSION%.SQL
rem If no parameter specified, abort
IF *%1==* GOTO END
rem Export PL/SQL code
call :PACKAGES
rem If we requested package export only, abort
IF *%1==*PACK_ONLY GOTO END
rem Make the version-specific path on the target server
md %TARGETPATH%%VERSION%
rem If second parameter is set to NOCOPY, don't copy the output PL/SQL code to the
rem target server
IF *%2==*NOCOPY GOTO :NOCOPY
rem Copy the output PL/SQL code to the target server
CALL :COPYPACKAGES
:NOCOPY
rem Export and copy each Apex application in turn
FOR %%f in (%APPLIST%) do call :APP %%f %2
goto END
:APP
rem Execute the java Apex application export script. The resulting Oracle
rem SQL script will be called f%1.sql (eg f123.sql)
java oracle.apex.APEXExport -db %JAVA_CONNECT% -user %JAVA_USER% -password %JAVA_PASSWORD% -applicationid %1
rem Read the exported Apex application SQL script and replace the security group id
rem with that of the workspace to which the application will be copied on the target server
perl rep.pl f%1.sql f%1_out.sql %WORKSPACE%
rem Copy the output script to the target server unless NOCOPY is specified as
rem the second parameter
rem Reply F to the XCOPY prompt "Does [File Path and Name] specify a file name
rem or directory name on the target (F = file, D = directory)?
IF NOT *%2==*NOCOPY ECHO F | xcopy f%1_out.sql %TARGETPATH%%VERSION%\f%1_out%TARGETSUFFIX%.sql /Y /I
goto :EOF
:SETDATETIME
for /F "tokens=1,2,3 delims=/ " %%a in ('date /t') do set LD=%%c%%b%%a
for /F "tokens=1,2 delims=:" %%a in ('time /t') do set LT=%%a%%b
set LT=%LT: =0%
set LD=%LD: =0%
set %1=%LD%_%LT%
goto :EOF
:PACKAGES
rem Create a temporary SQL script file
ECHO execute APEXTRAS_DEPLOYMENT.ALLCode('%PACKAGES_OUTFILE%','LIVE'); > %PACKAGES_DUMPSCRIPT%
ECHO QUIT >> %PACKAGES_DUMPSCRIPT%
rem Execute the temporary script
sqlplus %SQLPLUS_LOGON% @%PACKAGES_DUMPSCRIPT%
goto :EOF
:COPYPACKAGES
rem Copy the exported SQL script containing the PL/SQL code to the version-specific
rem path on the target server
xcopy %OUTPATH%%PACKAGES_OUTFILE% %TARGETPATH%%VERSION% /Y /I
rem Copy the stylesheet to the target server
xcopy %STYLESHEET_FROM_PATH%%STYLESHEET_NAME% %STYLESHEET_TO_PATH%%STYLESHEET_NAME% /Y /I
rem Copy image files that are newer than files of the same name on the target,
rem or that don't exist on the target
xcopy %STYLESHEET_FROM_PATH%*.jpg %STYLESHEET_TO_PATH% /D /S
xcopy %STYLESHEET_FROM_PATH%*.gif %STYLESHEET_TO_PATH% /D /S
xcopy %STYLESHEET_FROM_PATH%*.png %STYLESHEET_TO_PATH% /D /S
xcopy %STYLESHEET_FROM_PATH%*.psd %STYLESHEET_TO_PATH% /D /S
goto :EOF
:END
Back to Apex deployment script
[...] sample export batch file can be found here. It relies on a PL/SQL package, a PERL script, and the APEX utility APEXExport.class, which is in [...]
APEX Deployment Script at APEXtras
25 Jul 09 at 12:19