Re: Trailing spaces remove help?
Date: 12 Feb 93 11:55:50 +0100
Message-ID: <1993Feb12.115550.66_at_bmwf1f.bmwf.gv.at>
In article <1993Feb10.073834.3105_at_kaija.spb.su>, adn_at_kaija.spb.su (ADN communication group) writes:
> Hello everybody!
>
> I have Oracle V6 running at Unix ISC SysV. I am novice in Oracle.
> Please help me with removing trailing spaces in Oracle output.
>
> I have:
>
> Col_1 Col_2 Col_3
> ----------------------------------------------- -------------------- --------
> Name_name_name 2019 5
> Fa_la_la_la_la_la_la 987 0
> Etc_etc_etc 100201 900
> What must I do to get:
>
> Col_1 Col_2 Col_3
> -------------------- ------ -----
> Name_name_name 2019 5
> Fa_la_la_la_la_la_la 987 0
> Etc_etc_etc 100201 900
>
> The maximum length of output column must be equal to longest value in it.
> Or, If the alias name of the column longer then longest value in that
> column, the maxlength of the column should be equal to that alias.
>
> Is there a simple querty to do it.
> All suggestions will be appriciated!
> Thanks in advance!
> --
> Nick Maximov
> St. Petersburg, Russia
-- Try this ... ****************************** SQL - Script ************************** SET PAGESIZE 0 SET FEEDBACK OFF SET TERMOUT OFF SPOOL format.sql REM --- Creating a script to format the columns REM -- Col_1 SELECT 'COLUMN Col_1 FORMAT A'|| DECODE( TRUNC(LENGTH('col_1')/MAX(LENGTH(col_1))),0,MAX(LENGTH(col_1)), LENGTH('col_1')) FROM your_table / REM -- Col_2 SELECT 'COLUMN Col_2 FORMAT A'|| DECODE( TRUNC(LENGTH('col_2')/MAX(LENGTH(col_2))),0,MAX(LENGTH(col_2)), LENGTH('col_2')) FROM your_table / REM -- Col_3 SELECT 'COLUMN Col_3 FORMAT A'|| DECODE( TRUNC(LENGTH('col_3')/MAX(LENGTH(col_3))),0,MAX(LENGTH(col_3)), LENGTH('col_3')) FROM your_table / SPOOL OFF SET PAGESIZE 80 SET FEEDBACK ON REM -- Execute generated format script START format.sql SET TERMOUT ON REM -- Execute Your Script SELECT col_1,col_2,col_3 FROM your_table / . . . . ***************************************************************************** kind regards Mike ================================================================================ ^ Federal Ministry of Science and Research B | M <-------------------------------------------------------------------------+----> Computer Center W | F | Ing. Klaus-Michael Hatzinger mail: hatzinger_m_at_bmwf1f.bmwf.gv.at | Bankgasse 1/209 phone: 0043-222-53120/5188 | 1014 Vienna, Austria fax: 0043-222-53120/5155 V ================================================================================Received on Fri Feb 12 1993 - 11:55:50 CET