1,105,226 Community Members

oracle and shell scripting

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

needed help how can i connect to my oracle database using shell script and how can i assign particular value in table to a variable defined in shellscript and i use sqlplus but i get error

Member Avatar
Watael
Junior Poster
134 posts since Apr 2012
Reputation Points: 4 [?]
Q&As Helped to Solve: 27 [?]
Skill Endorsements: 2 [?]
 
0
 

show what you've done.

all our cristal balls are broken ;)

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

hi
i use the following code but i get this error
./cv.txt: line 17: unexpected EOF while looking for matching ``'
./cv.txt: line 29: syntax error: unexpected end of file
the file is too big so i write just the part to connect to database

ORACLE_VALUE=`sqlplus -s scott/ZooM1990 << EOFSQL
set head off
select * from emp where empno=7369;
EOFSQL'
echo $ORACLE_VALUE

i also use another code but i get this error
line 18: syntax error near unexpected token from' ./test: line 18:select * from dual'
here is the code

sqlplus / as sysdba
select * from dual
exit

i use another way but i also get an error
syntax error near unexpected token from' ./V: line 21:select ename from emp;'
the code is

sqlplus -s sys as sysdba < startup
spool on;
spool ashu;
connect scott/tiger
select ename from emp;
spool off;
exit;
EOF
cat ashu 

so do you have any way that you could help me ???

Member Avatar
Watael
Junior Poster
134 posts since Apr 2012
Reputation Points: 4 [?]
Q&As Helped to Solve: 27 [?]
Skill Endorsements: 2 [?]
 
0
 

hi lena1990,

what do you do with the variable after assigning it? is it worth assigning it? couldn't you pipe sqlplus to 'what uses the variable' instead?

the first form has to be within backquotes, not backquote and quote.

you really should consider using modern command substitution $( )

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

what s the moden command subsition could you explain more

Member Avatar
Watael
Junior Poster
134 posts since Apr 2012
Reputation Points: 4 [?]
Q&As Helped to Solve: 27 [?]
Skill Endorsements: 2 [?]
 
0
 

modern command substitution is $( )

$ var=$(date +%F)
$ echo "$var"
2012-12-10
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article