Home » SQL & PL/SQL » SQL & PL/SQL » trim - not working (oracle )
trim - not working [message #517917] Fri, 29 July 2011 08:17 Go to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member
I am using trim function in my select query. But still I am getting white space in my output. because of this, I am getting the error "value too large for column... " when I load the data into a table through sqlloader.

Can yo please help me how to avoid the white space effectively?

define APPName="&1"
set heading off;
set verify off;
set newpage 0
set feedback off;
set rtrimspool on;
set termout off;
set pagesize 40000;
set lines 220;
col db_name form a15;
col app_id form a20;
set colsep ',';
col OWNER form a25;
col TABLE_NAME form a35;
COLUMN DB_NAME NEW_VALUE _DB_NAME NOPRINT
SELECT rtrim(NAME) DB_NAME  FROM v$database;
COLUMN DB_NAME PRINT
spool &APPNAME._&_DB_NAME._html_table_stats_rpt.csv
select rtrim(sysdate) report_date,
(select rtrim('&APPName') from dual) App_name,
(select rtrim('&_DB_NAME') from dual) db_name,
rtrim(owner),
rtrim(table_name), 
rtrim(last_analyzed),
rtrim(NUM_ROWS)
from dba_tables 
where owner not in('MGMT_VIEW',
'SYS',
'SYSTEM',
'DBSNMP',
'SYSMAN',
'OUTLN',
'MDSYS',
'ORDSYS',
'EXFSYS',
'DMSYS',
'WMSYS',
'CTXSYS',
'ANONYMOUS',
'XDB',
'ORDPLUGIN',
'SI_INFORM',
'N_SCHEMA',
'OLAPSYS',
'TSMSYS',
'BI',
'PM',
'MDDATA',
'IX',
'SH',
'DIP',
'OE',
'HR',
'PERFSTAT')
and last_analyzed < add_months(sysdate,-1) 
order by last_analyzed,owner;

29-Jul-11	APP00111_1                      	FASTREPE       	REP2_BACKUP                   	FR_UNEXCEPTED_ERRORS          	15-Nov-09	0
29-Jul-11	APP00111_1                      	FASTREPE       	REP2_BACKUP                   	AUDIT_DDL                     	15-Nov-09	0
29-Jul-11	APP00111_1                      	FASTREPE       	CDMC_ADMIN                    	CDMCDATA                      	15-Nov-09	8448042
29-Jul-11	APP00111_1                      	FASTREPE       	CDMC_ADMIN                    	CDMC_LOG                      	15-Nov-09	0
29-Jul-11	APP00111_1                      	FASTREPE       	CDMC_ADMIN                    	CDMC_DEBUG                    	15-Nov-09	0
Re: trim - not working [message #517919 is a reply to message #517917] Fri, 29 July 2011 08:22 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
I do not understand. This is a SELECT statement. I do not see anything to do with with SQL*Loader here.

TRIM does not work on columns defined as CHAR as they will be padded with whitespace no matter what do you.
Re: trim - not working [message #517920 is a reply to message #517919] Fri, 29 July 2011 08:24 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I am using trim function in my select query. But still I am getting white space in my output. because of this, I am getting the error "value too large for column... " when I load the data into a table through sqlloader.

why are you going out to a flat file if the data eventually goes back into an DB?
Re: trim - not working [message #517924 is a reply to message #517920] Fri, 29 July 2011 08:50 Go to previous message
Michel Cadot
Messages: 68770
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
And using
(select rtrim('&APPName') from dual)
in SELECT clause is quite silly.
Why not
(select (select (select (select (select rtrim('&APPName') from dual) from dual) from dual) from dual)

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.


Regards
Michel

[Updated on: Fri, 29 July 2011 08:52]

Report message to a moderator

Previous Topic: do you recommend parallel index ?
Next Topic: Spanish
Goto Forum:
  


Current Time: Thu Sep 04 14:27:49 CDT 2025