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

Recommended Answers

All 5 Replies

show what you've done.

all our cristal balls are broken ;)

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 ???

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 $( )

what s the moden command subsition could you explain more

modern command substitution is $( )

$ var=$(date +%F)
$ echo "$var"
2012-12-10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.