sqlplus call


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sqlplus call
# 1  
Old 06-02-2008
sqlplus call

I have a .sh file which acts as an all set for a couple of oracle scripts i want to call. Basically it has 3 variables, the user Id, the password, and the oracle instance to connect to.. the problem is I cant seem to get the connection string format properly.. the program essentially is this:

-----------------------

SYSTEM_UID=SYSTEM
SYSTEM_PWD=SYSTEM
DATABASE=myDatabase

CREATEUSERCMD="sqlplus ${SYSTEM_UID}/${SYSTEM_PWD}@${DATABASE}"

echo Printing user Id: ${SYSTEM_UID}
echo Printing pwd: ${SYSTEM_PWD}
echo Printing db: ${DATABASE}
echo Printing connection string: ${CREATEUSERCMD}

----------------------------

Resulting output I get is:

$ bash allset.sh
Printing user Id: SYSTEM
Printing pwd: SYSTEM
Printing db: myDatabase
@myDatabasennection string: sqlplus SYSTEM

Am I resolving those slashes and ampersands incorrectly? Or is there an issue with the way I'm referencing those variables? If I hard code the connection string as:

CREATEUSERCMD='sqlplus SYSTEM/SYSTEM@myDatabase'
and then just call : ${CREATEUSERCMD} it works fine.
# 2  
Old 06-05-2008
Depends on what you are trying to do. For example

Code:
SQL_RESULT=`sqlplus -s "${USERID}/${PASSWORD}@${ORA_SID}" << EOF 
    
  -- sqlplus commands here...
    
exit

EOF`

will cause the result of your SQL*Plus script to be saved in variable SQL_RESULT. Note the back-ticks. You could then

echo "$SQL_RESULT" to see the result.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

2. Shell Programming and Scripting

Sqlplus error - sqlplus -s <login/password@dbname> : No such file or directory

i am using bash shell Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127. IFS="," declare -a Arr=($Variable1); SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE} echo "set head off ; " > ${SQLCMD} echo "set PAGESIZE 0 ;" >> ${SQLCMD}... (6 Replies)
Discussion started by: arghadeep adity
6 Replies

3. Shell Programming and Scripting

Sqlplus Help

When i run the following script am getiing the output correct but i want to get it in the form of a table, could any one help me please. the script is a s follows count=`sqlplus -s $ORACLE_ACCOUNT << EOF set heading off set wrap on set feedback off column ChangeNumber format a12 column... (9 Replies)
Discussion started by: jhon1257
9 Replies

4. UNIX for Dummies Questions & Answers

Why do I need to call make if I call gcc ?

Why do I need to call make if I call gcc ? I thought gcc already compiles the sources. thanks (1 Reply)
Discussion started by: aneuryzma
1 Replies

5. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

6. Shell Programming and Scripting

Call sqlplus in the shell script

Hi, I am writing a script to test database connection. If the first try fails, it will wait for 1 minutes and then try again. The script is as following: ........ for i in $ORACLE_SID do $ORACLE_HOME/bin/sqlplus $username/$password@$i <<! >/dev/null select * from tab; exit if ; then... (3 Replies)
Discussion started by: beaniebear
3 Replies

7. HP-UX

how can i call sqlplus?

i am new working with hp-ux but i had to because of my job. so i want to execute some sql scripts but when i call sqlplus to run them it responds /sbin/sh: sqlplus not found. i have oracle 8.1.7 installed. what should i do sorry if this sounds too easy but i am now learning. The same... (13 Replies)
Discussion started by: theodore
13 Replies

8. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

9. Shell Programming and Scripting

Sqlplus

I am looking to loop round a load of files and execute each in sqlplus, I have looked at the forum to see what was posted in the past, but most of the examples seem to use the sql being passed in through the script, which is not really what I am looking for, can someone tell me if the code below is... (9 Replies)
Discussion started by: LiquidChild
9 Replies
Login or Register to Ask a Question