How to export files from Oracle Apex workspace using command line? - oracle

One simpler way is:
Go to https://apex.oraclecorp.com then login into the workspace using credentials.After that click on SQL scripts and proceed to download or export the SQL's.
But is there any way by which we can directly export/download all the sql files via command line ?

You can quickly export Apex applications through the command line, avoiding the Apex UI completely. To do this, Oracle has provided two java classes, which are included in the Apex download:
APEXExport.class
APEXExportSplitter.class
These classes are located in the apex/utilities/oracle/apex directory.
Before using these classes, you have to make sure that the following environment variables are set up correctly:
ORACLE_HOME should point to just that. Something like:
/u01/app/oracle11g/product/11.2.0/db1
APEX_HOME should point to the directory where you unzipped the Apex download. For example
/u01/downloads/apex
PATH needs to include $ORACLE_HOME/jdk/bin
CLASSPATH needs to include:
$ORACLE_HOME/jdbc/lib/ojdbc5.jar
$APEX_HOME/utilities
Note: You may also have to include the . path.
APEXExport
To execute the export use
$ java oracle.apex.APEXExport
You can get a list of the available arguments by executing the above command without arguments. For a basic application export use:
$ java oracle.apex.APEXExport -db localhost:1521:db1 -user scott -password tiger -applicationid 100
You’ll get a message saying: Exporting application 100.
Once the export is done you’ll see an *sql file in your current directory (e.g. f100.sql).
APEXExportSplitter
You can now take the export file and split it up into its various components. This is handy if, for example, you want to examine the SQL of an application page or two.
$ java oracle.apex.APEXExportSplitter f100.sql
This program creates a directory named after your application (e.g. f100) and multiple sub directories which contain the various components of the application.

Related

Create a Git Alias specific to one project

I have a Python project that is compiled using pyinstaller. It usually uses a bunch of concatenated operations && to not only compile, but perform several other things. Ok, just a big command.
I can use an alias with git bash to reduce it to a single word, fine. But I want to know, if exists some way to distribute some bash file with that alias with my project.
I mean, in my repo, having something like alias.sh that contains the alias I want, but they just exists inside that repo, so whenever I open a terminal inside that repo, I already have present those alias. And if someone forks or clones my project, they already have that alias too thanks to that specific file.
No, it's not possible.
But you can create a script file alias.sh to set up the alias and instruct users of your repo via README file to source this file once in their terminal session when they need this alias: . ./alias.sh
The file alias.sh might contain:
#!/bin/sh
alias youralias='your | long | command'
After the file was sourced with . ./alias.sh, you can simply run youralias as a standalone command.

append a parameter to a command in the file and run the appended command

I have a the following command in a file called $stat_val_result_command.
I want to add -Xms1g parameter at the end of the file so that is should look like this:
<my command in the file> -Xms1g
However, I want to run this command after append. I am running this in a workflow system called "nextflow". I tied many things, including following, but it does not working. check the script section which runs in Bash by default:
process statisticalValidation {
input:
file stat_val_result_command from validation_results_command.flatten()
output:
file "*_${params.ticket}_statistical_validation.txt" into validation_results
script:
"""
echo " -Xms1g" >> $stat_val_result_command && ```cat $stat_val_result_command```
"""
}
Best to avoid appending to or manipulating input files localized in the workdir as these can be, and are by default, symbolic links to the original files.
In your case, consider instead exporting the JAVA_TOOL_OPTIONS environment variable. This might or might not work for you, but might give you some ideas if you have control over how the scripts are being generated:
export JAVA_TOOL_OPTIONS="-Xms1g"
bash "${stat_val_result_command}"
Also, it's generally better to avoid localizing and running scripts like this. It might be unavoidable, but usually there are better options. For example, third-party scripts, like your Bash script could be handled more simply:
Grant the execute permission to these files and copy them into a
folder named bin/ in the root directory of your project repository.
Nextflow will automatically add this folder to the PATH environment
variable, and the scripts will automatically be accessible in your
pipeline without the need to specify an absolute path to invoke them.
This of course assumes you can control and parameterize the process that creates your Bash scripts.

What to do about "no ocijdbc11 in java.library.path" SQL Developer error

I am trying to get create a TNS connection in SQL Developer on my mac laptop (OS X 10.9.5).
I get this error no ocijdbc11 in java.library.path I googled around and found out that I need to
install oracle's instant client. I found the instance client files here :
http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
The files are just zip files that you need to download and extract somewhere.
Then I found the instructions that actually tell you what to do with the zip files here:
https://docs.oracle.com/cd/E11882_01/install.112/e38228/inst_task.htm#BABHEBIG
The instructions say that :
Set the DYLD_LIBRARY_PATH and the NLS_LANG environment variables
to the full path of the instantclient_11_2 directory. For example,
if you unzipped the Instant Client zip file in the /bin/oracle
directory, then set the DYLD_LIBRARY_PATH environment variable to
/bin/oracle/instantclient_11_2.
What the instructions do not tell me is HOW to set environment variables permanently and how to make the environment variables accessible to GUI tools like SQL developer.
Has anyone gotten SQL Developer to work with instantclient?
Based on the answer of #Alex Poole: In El Capitan when SIP is enabled, this doesn't seem to work, because the DYLD_LIBRARY_PATH environment variable doesn't get transferred to the environment that bash ./sqldeveloper starts (last line of the SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh) .
Solution: instead of editing the file SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh I edited the file SQLDeveloper.app/Contents/Resources/sqldeveloper/sqldeveloper/bin/sqldeveloper and added the export DYLD_LIBRARY_PATH=/path/to/instantclient line there.
#!/bin/bash
export DYLD_LIBRARY_PATH=/path/to/instantclient
#=============================================================================
# Launcher for Oracle SQL Developer
# Copyright (c) 2005, Oracle. All rights reserved.
#=============================================================================
...
If you're comfortable editing files, you can set the library path in the internal startup script. I edited this through Terminal.app and vim, by going to:
cd <wherever SQL Developer was installed/unzipped>
cd SQLDeveloper.app/Contents/MacOS
cp -p sqldeveloper.sh sqldeveloper.sh.backup
chmod o+w sqldeveloper.sh
vim sqldeveloper.sh
The file is protected by default, so I'm changing it to be writable (and making a backup first, just in case). If you skip that step, with vim you can save it with :w! to save it anyway.
Alternatively find the SQLDeveloper application in Finder, right click, and choose 'Show Package Contents', then drill down to Contents->MacOS, right-click the sqldeveloper.sh file and choose 'Open With' and your favourite text editor - TextEdit will do. As the file is locked you will be prompted to unlock it at some point - maybe on open or first edit, but TextEdit will ask you if you want to unlock it when you save.
However you get into the file, you can then specify add a line to set/export DYLD_LIBRARY_PATH:
#!/bin/bash
# Next line added for TNS connections
export DYLD_LIBRARY_PATH=/path/to/instantclient
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
here="${0%/*}"
cd "${here}"
cd ../Resources/sqldeveloper/sqldeveloper/bin
bash ./sqldeveloper -clean >>/dev/null
... where /path/to/instantclient is your unzipped directory; in the quoted example above, that would be /bin/oracle/instantclient_11_2. Also note that this needs to be the 64-bit instant client; it will complain about the wrong architecture if you try to use the 32-bit version.
One the modified file has been saved, relaunch SQL Developer and your TNS connection should now work. If you want to be able to use a TNS alias you can also set/export a TNS_ADMIN variable that points to a directory containing a tnsnames.ora file.

Saving SQL files into specific folders in Oracle

I am using Oracle 11g. When I open a new SQL file writing the command
ed filename.sql
A new file is created in my bin folder with the name as filename but, I want them to be in separate folders for my convenience. I am developing 3 application(well for my practice only). I want them to store in different folders for each project. I tried all of the following none of them worked please tell me how can I save the files into specific folders.
ed erp/logindetails.sql
ed 'erp/logindetails.sql'
ed "erp/logindetails.sql"
ed 'erp\logindetails.sql'
ed erp\logindetails.sql
These commands except where I used "" worked and opened the default text editor with the name afiedt.buf which I am getting when I enter only edit. No files are created with any of the above command.
You're giving EDIT a relative path to the file; since your current working directory seems to be the bin directory that the SQL*Plus directory is in (is this Windows, and are you running a shortcut that sets the working directory, maybe?) it will try to create a file like %ORACLE_HOME%\bin\erp\logindetails.sql, and you're unlikely to have created an erp directory there. Giving the full path to the directory will work:
edit c:\users\dibya\projects\erp\logindetails.sql
for example.
As noted in the documentation, EDIT will search for existing files, but that involves setting an environment variable - which you'd have to change as you move between the projects. You might find it easier to edit the files in the OS and just run them from SQL*Plus.
You might also be able to use separate shortcuts to launch SQL*Plus for each project, each setting the 'start in' directory to a project-specific location - then just edit logindetails.sql would be looking in the right place by default. Or, from a command prompt cd into the relevant project-specific directory and launch SQL*Plus from there, which is effectively what a shortcut would do.

Where do I put mxmlc so that I could just type 'mxmlc' in the terminal to compile a swf file?

I'm on a Mac and I'm trying to make a Vim plugin for compiling/running actionscript files.
First, I need to run mxmlc on the command line, but to do that I have to keep on typing the path to it. Where do I place it so that I don't have to retype the path?
You need to modify your "$PATH" environment variable, so that the tool is in that directory. However, if you want to make this very easy... you can download my macosx-environment-setup.tar.bz2 program. If you execute the "install.sh" script using "sudo ./install.sh", it will setup your environment in such a way that if you use "/Library/Flex4SDK" as the location for the Flex4SDK, it will automatically find it, define FLEX_HOME to point to that location, and it will also ensure that the binaries from the Flex4SDK are in your PATH.
Side Note: This is up on the web, because I use it in my Development Environment Setup How-To Guides. If you aren't too keen about running "sudo ./install.sh", you need to choose a location (I am going to assume "/Library/Flex4SDK", so that the tools are located in "/Library/Flex4SDK/bin"), and then you would simply need to edit your "~/.profile" file (using "nano ~/.profile"), adding the following to the very end:
export FLEX_HOME=/Library/Flex4SDK
export PATH="$PATH":"$FLEX_HOME/bin"
Note that these changes occur in your shell... they will not affect programs that are launched by double-clicking them in Finder. In order to affect those programs, you will need to place the environment variables in a file named ~/.MacOSX/environment.plist. See Automatically build ~/.MacOSX/environment.plist for a script that will automatically generate such a file using the current environment variables defined in your shell.
There are a few ways to answer this:
In one of your directories searched
by PATH (see the list with echo
$PATH)
Add a new directory to PATH
(e.g. in your ~/.bashrc
export PATH=$PATH:/path/to/bindir)
Add an
alias to your program (e.g. in your
~/.bashrc alias
mxmic=/path/to/mxmic)
(I'm assuming you're using bash shell, which is usually the case you can check with echo $SHELL)

Resources