How to remove unnecessary line breaks in SQL Plus

2019-02-28 10:56发布

问题:

I am spooling a package from a database and this is what I get:

CREATE OR REPLACE PACKAGE BODY "CPI"."GIPI_WBOND_BASIC_PKG"                   
    AS                                                                              
       FUNCTION get_gipi_wbond_basic (p_par_id gipi_wbond_basic.par_id%TYPE)        
          RETURN gipi_wbond_basic_tab PIPELINED                                     
       IS                                                                           
          v_wbond   gipi_wbond_basic_type;                                          
       BEGIN                                                                        
          FOR i IN (SELECT a.par_id,        a.obligee_no,    a.bond_dtl,      a.inde
    mnity_text,                                                                     
                           a.clause_type,   a.waiver_limit,  a.contract_date, a.cont
    ract_dtl,                                                                       
                           a.prin_id,       a.co_prin_sw,    a.np_no,         a.coll
    _flag,                                                                          
                           a.plaintiff_dtl, a.defendant_dtl, a.civil_case_no        
                      FROM gipi_wbond_basic a                                       
                     WHERE a.par_id = p_par_id)  

And I am expecting it to be something like this:

CREATE OR REPLACE PACKAGE BODY cpi.gipi_wbond_basic_pkg
AS
   FUNCTION get_gipi_wbond_basic (p_par_id gipi_wbond_basic.par_id%TYPE)
      RETURN gipi_wbond_basic_tab PIPELINED
   IS
      v_wbond   gipi_wbond_basic_type;
   BEGIN
      FOR i IN (SELECT a.par_id, a.obligee_no, a.bond_dtl, a.indemnity_text,
                       a.clause_type, a.waiver_limit, a.contract_date,
                       a.contract_dtl, a.prin_id, a.co_prin_sw, a.np_no,
                       a.coll_flag, a.plaintiff_dtl, a.defendant_dtl,
                       a.civil_case_no
                  FROM gipi_wbond_basic a
                 WHERE a.par_id = p_par_id)

Please help me on how can I get rid of those new lines and ugly format. Thanks!

回答1:

Ok this one solved my problem.

From this,

SET HEADING OFF;
SET ECHO OFF;
SET PAGES 999;
SET LONG 999999;

I added this:

SET LONGCHUNKSIZE 999999;
SET PAGESIZE 0;
SET LINESIZE 500;


回答2:

You can do it using the regular expression in SSMS:

1) Ctrl-H to bring up the Find And Replace window 2) Select USE -> Regular Expressions 3) Put ^\n in the Find What 4) Keep Replace With empty 5) Click Replace (All)

Good luck -- Nilesh Umaretiya (India)