Taken from Source Found on GitHub
Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions rem of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
This repository is a demonstration of using ODBCapture to capture the source code from Oracle's Sample Schema
Files/Folders | Description |
---|---|
builds | Build Scripts and Logs |
custom_data_load | Special Data Load not handled by ODBCapture |
grb_linked_install_scripts | Common Scripts Linked by Installation Scripts |
grbsdo | ODBCapture Optional Spatial Data Option |
grbsrc | ODBCapture Main Installation Scripts |
grbxrep | ODBCapture XML DB Repository Objects/Data |
orig_install | Original Schema Installation Documentation |
ss_grb | ODBCapture Configuration Data for Sample Schema |
ss_src | Sample Schema Source Code (includes configuration data) |
ss_tdat | Sample Schema Test Data |
Note: Sample build scripts are available for different versions of the Oracle database in the builds
folder.
- Copy these folders to a location with SQL*Plus and SQL*Loader.
- custom_data_load
- grb_linked_install_scripts
- ss_src
- Install Source Code
- Move to Installation Folder:
cd ss_src
- Connect to Database as SYS:
sqlplus SYS/PASSWORD@TNS_ALIAS as sysdba
- Run Main Installation Script:
@install.sql "SYSTEM/PASSWORD@TNS_ALIAS"
- Run installation reports:
@report_status.sql "SYSTEM/PASSWORD"
- Exit from SQL*Plus:
exit
- Review results from installation reports
- Move to Installation Folder:
- Install Custom Loaded Data
- Move to Installation Folder:
cd ../custom_data_load
- Connect to Database as SYS:
sqlplus SYS/PASSWORD@TNS_ALIAS as sysdba
- Run Main Installation Script:
@install.sql "SYSTEM/PASSWORD@TNS_ALIAS"
- Run the installation reports:
@report_status.sql "SYSTEM/PASSWORD"
- Exit from SQL*Plus:
exit
- Review results from installation reports
- Move to Installation Folder:
Note: The sample build scripts in the builds
folder include these installations.
For each of the following folders, repeat steps 1 and 2 above, in this order:
- ss_tdat
- grbsrc
- grbsdo
- grbxrep
- ss_grb
To generate the source code from the database after installation, log into the database as ODBCAPTURE and run these commands. Some modification will be needed if:
- Not running on Linux
- Database cannot write to `/opt/install_files'
----------------------------------------
-- Sample Schema Capture
execute ODBCAPTURE.FH2.clear_buffers;
set serveroutput on size unlimited format word_wrapped
execute ODBCAPTURE.COMMON_UTIL.update_view_tabs;
execute ODBCAPTURE.GRAB_SCRIPTS.all_scripts('ss_src');
execute ODBCAPTURE.GRAB_SCRIPTS.all_scripts('ss_tdat');
execute ODBCAPTURE.GRAB_SCRIPTS.all_scripts('ss_grb');
delete from zip_files where file_name = 'ss.zip';
execute ODBCAPTURE.FH2.write_scripts('ss.zip', '/opt/install_files');
commit;
After those commands are complete, there will be an /opt/install_files/ss.zip
file ready. The ZIP file will contain 3 folders that match the source code from the original:
- ss_grb
- ss_src
- ss_tdat
An alternative is to use execute ODBCAPTURE.FH2.write_scripts('ss.zip');
instead, then download the ZIP file from the ODBCAPTURE.ZIP_FILES table.Retreival of that ZIP file can be done using one of the following.
- APEX GUI Application
- SQL-Developer
- SQL-Developer Plug for VS Code
The capture_files.sql SQL script can also be used for source code capture if the ODBCAPTURE_INSTALLATION_LOGS table has been created and includes records for all the needed BUILD TYPES. This SQL script runs correctly in SQL*Plus, but will require Base64 decoding before it can be unzipped.