---
title: "spool"
author: "andyniu"
date: "2016-09-23T15:17:15Z"
tags: []
categories: ["数据库"]
slug: "spool"
draft: false
lastmod: "2016-09-23T15:17:15Z"
id: 2326466
url: "https://andyniu.iteye.com/blog/2326466"
---

set head off;  
set feed off;  
set define off;  
set autoprint off;  
set termout off;  
set heading off;  
set flush off;  
set feedback off;  
set pagesize 0;  
set linesize 18000;  
set echo off;  
set trim on;  
set trimspool on;  
spool /tmp/testdc.TXT;  
select ''|| REPLACE(REPLACE(REPLACE(TRIM(PROVINCE\_CUST\_ID),chr(9),''),chr(13),''),chr(10),'') || ','  
      || REPLACE(REPLACE(REPLACE(TRIM(GROUP\_ID),chr(9),''),chr(13),''),chr(10),'') || ','  
      || REPLACE(REPLACE(REPLACE(TRIM(CUST\_NAME),chr(9),''),chr(13),''),chr(10),'') ||  ','  
      || REPLACE(REPLACE(REPLACE(TRIM(CBSS\_CUST\_ID),chr(9),''),chr(13),''),chr(10),'') || ','  
      || REPLACE(REPLACE(REPLACE(TRIM(EPARCHY\_CODE),chr(9),''),chr(13),''),chr(10),'') || ','  
      || (select  REPLACE(REPLACE(REPLACE(TRIM(c.AREA\_NAME),chr(9),''),chr(13),''),chr(10),'')  
        from td\_m\_political\_location c where c.area\_code = t.eparchy\_code),chr(13) || chr(10) || ''  
  from tf\_f\_cust\_group\_p51 t  
  where cust\_id = 16070501 ;  
spool off  
exit;  
EOF