1
我是新来的通过SSH(腻子)终端在Ubuntu操作系统上使用ORACLE,我的工作站有Windows操作系统。ORACLE数据库的Ubuntu Shell脚本
我编程连接到Oracle数据库,然后导出表到一个文本文件,然后删除取决于column's值一些记录一个壳。
没有SQL Plus被安装,这是必须的,因为我们需要模拟我们的客户的infraestructure。
这是脚本的代码的一部分:
#!/bin/bash
su oracle
export ORACLE_SID=ORA_SID
export ORACLE_HOME=/uxx/app/oracle/product/11.2.0/client_1
export TWO_TASK=[hostname]:[port]/[ORA_SID]
isql -v [db] [user] [pass] <<EOF
CREATE OR REPLACE DIRECTORY test AS '/xxx/yyy/';
DECLARE
f utl_file.file_type;
BEGIN
f := utl_file.fopen('TEST','sample.txt','W');
for s in (select * from [table]);
loop
utl_file.put_line(f,s);
end loop;
utl_file.fclose(f);
END;
quit;
exit
EOF
当我跑我得到了下面的输出脚本:
SQL> SQLRowCount returns -1
SQL> [S1000][Oracle][ODBC][Ora]ORA-06550: line 1, column 7:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
begin function pragma procedure subtype type <an identifier>
<a double-quoted delimited-identifier> current cursor delete
exists prior
[ISQL]ERROR: Could not SQLExecute
SQL> [37000][Oracle][ODBC][Ora]ORA-00900: invalid SQL statement
[ISQL]ERROR: Could not SQLExecute
SQL> [S1000][Oracle][ODBC][Ora]ORA-06550: line 1, column 5:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
(begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
[ISQL]ERROR: Could not SQLExecute
SQL> [37000][Oracle][ODBC][Ora]ORA-00900: invalid SQL statement
[ISQL]ERROR: Could not SQLExecute
SQL> [37000][Oracle][ODBC][Ora]ORA-00900: invalid SQL statement
[ISQL]ERROR: Could not SQLExecute
SQL> [37000][Oracle][ODBC][Ora]ORA-00900: invalid SQL statement
任何帮助将不胜感激。
一方面,后声明 – OldProgrammer 2014-10-06 20:04:03
确定仅仅是为了记录Ichecked与两个分号,没有它,得到同样的错误,别无分号。 – Cabrakan 2014-10-06 20:17:55
你在'end'后面缺少一个'/';'http://stackoverflow.com/a/10207695/330315(当然,这只适用于SQL * Plus - 我不知道'isql'工具是什么你正在使用的。这可能有不同的规则来定义一个替代分隔符) – 2014-10-06 21:37:39