:
This command is used to make a query to oracle using SQL Plus and a username/password/host. Prior you need to define Oracle enviroment variables.
Module data
Sample Oracle enviroments variables:
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server export ORACLE_SID=XE export ORACLE_VER=10.2.0 export PATH=$PATH:$ORACLE_HOME/bin
Sample query:
echo "SELECT USER_ID FROM DEMO_USERS where USER_NAME = 'ADMIN';" | /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/sqlplus -S -L hr/hr@localhost | tail -2 | head -1 | awk '{ print $1 }'
Dont miss the final “;” at the end of SQL sentence
(Visited 548 times, 2 visits today)