从oracle到unix获取多行记录时遇到问题

时间:2015-06-22 14:16:09

标签: sql oracle shell unix oracle-sqldeveloper

我从Oracle获取数据到UNIX平面文件。对于一列,有一条记录具有新行字符。 例如:Oracle表

ID   Comment            Date
1    my name **\n**     1111/11/11
     is **\n**
     abc
2    second comment     1111/11/11

当我在UNIX上使用SQLPlus获取此类记录时,每个换行符都在不同的行中。

请参阅下面的示例。

Unix文件:

ID|    Comment   |Date
 1|my name**\n** |1111/11/11 
 |is **\n**|
 |abc|
 2|second comment|1111/11/11

如何在UNIX平面文件中将这些记录作为单行而不是3个单独的行获取?

在shell脚本中使用以下代码:

sqlplus -s userid/password@database << EOF > abc.txt
set colsep |
set echo off;
set heading on;
set feedback off;
set pagesize 0 embedded on;
set linesize 10000;
SET trims ON;
set trimspool on;
@abc.sql
exit;
EOF

我想在UNIX文件中使用以下格式的结果。请建议。

ID|    Comment   |Date
 1|my name is abc|1111/11/11
 2|second comment|1111/11/11

0 个答案:

没有答案