尝试从shell脚本连接到oracle数据库

时间:2015-03-26 14:39:15

标签: oracle shell unix

我正在尝试从shell脚本连接到oracle数据库(我是新用户)。然后,该脚本将传递查询并将结果传输到名为canadacount的变量。我编写了代码,但它不起作用

#this script will attempt to connect to a remote database CFQ143 with user ID 'userid' and password 'password'.
#After loggin in it will read data from the PLATFORMSPECIFIC table.
#We can pass a query 'select count (platform) from platformspecific where platform='CANADA';
#The result from this query will be passed to a variable called canadacount which we can then echo back to the user.

canadacount='$ORACLE_HOME/bin/sqlplus -s /nolog<<EOF
connect userid/passsword@CFQ143:1521:CFQ143
set pages 0 feed off
select count (platform) from platformspecific where platform='CANADA';
exit
EOF'
echo $canadacount

1 个答案:

答案 0 :(得分:0)

答案是:

我将连接线更改为以下内容:

connect userid/passsword@CFQ143