SQL*Loader Date error (ORA-01858) 2005-12-09 - By brian.x.wisniewski@(protected)
Madhavi, did you get this figured out? I hadn't seen a reply on the list. When I run into issues like this I typically create a table with all varchar fields and load into that table to check if what I'm loading into the columns is what I expected to. Often it's not and adjustments need to be made in the control file. I also prefer external tables - just preference. I create the external table as varchars and then do the manipulation on the fields during the select from the external. rbld=`$SQL >> $OUT_FILE << !REBUILD create directory $BASE_DIR_NAME as '$BASE_DIR'; create directory $LOG_DIR_NAME as '$LOG_DIR'; grant read,write on directory $BASE_DIR_NAME to $OWNER, bwisniewski; grant read,write on directory $LOG_DIR_NAME to $OWNER, bwisniewski; create table $EXT_TABLE (BAN varchar2(9), NAME varchar2(20), ADDRESS varchar2(25), CITY varchar2(12), STATE varchar2(2), ZIP varchar2(5), SUBSCRIBER varchar2(10), BALANCE varchar2(8)) organization external (type oracle_loader default directory $BASE_DIR_NAME access parameters (records fixed 99 delimited by newline badfile $LOG_DIR_NAME:'$BAD_FILE' logfile $LOG_DIR_NAME:'$LOG_FILE' discardfile $LOG_DIR_NAME:'$DIS_FILE' load when (ban notequal blanks and subscriber notequal blanks) fields lrtrim( BAN (1:+9), NAME (*:+20), ADDRESS (*:+25), CITY (*:+12), STATE (*:+2), ZIP (*:+5), SUBSCRIBER (*:+10), BALANCE (*:+8))) location ($BASE_DIR_NAME:'$FTP_FILE')) reject limit unlimited; !REBUILD` ... This is where I do the formatting and conversion to a number.. insert into $TABLE (ban, name, address, city, state, zip, subscriber, balance) select ban, name, address, city, state, zip, subscriber, to_number(ltrim(balance,'0'))/100 from $EXT_TABLE; - Brian Madhavi Kanugo <MKanugo@(protected)> Sent by: oracle-l-bounce@(protected) 12/07/2005 01:19 PM Please respond to MKanugo To: "'oracle-l@(protected)'" <oracle-l@(protected)> cc: Subject: SQL*Loader Date error (ORA-01858 (See ORA-01858.ora-code.com )) Hello All, I'm trying to load data using SQL Loader and ran into the ORA-01858 (See ORA-01858.ora-code.com ): a non-numeric character was found where a numeric was expected error. Below is my control file. As you can see, the timestamp is a constant field and I am loading its value from the filename of the data files. I am executing the sql loader from a shell script and creating the control file on the fly. The filename is in the form of: 20051206130101.txt So basically, the shell script replaces the when_changed value with 20051206130101. I created a temp table with just a date field and tried to insert a value into it. Insert into temp values (to_date('20051207160752', 'YYYYMMDDHH24MISS')); and there is no error and date conversion is implict. But SQLLOADER is erring out on ORA-01858 (See ORA-01858.ora-code.com ). LOAD DATA INFILE FILENAME APPEND INTO TABLE RE_STATS_STAGING FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS ( RE_NAME, TG_TYPE, TRUNKGROUP, CONNECTS, HANGUPS, DECLINES, LOOPS, SECONDS, CC_CONNECTED, CC_SETUP, TIMESTAMP CONSTANT "to_date('_when_changed_','YYYYMMDDHH24MISS')" ) Any ideas on where I am going wrong? Any thoughts or help will be appreciated. Thanks in advance, Madhavi <br><font size=2 face="sans-serif">Madhavi, did you get this figured out? I hadn't seen a reply on the list. </font> <br> <br><font size=2 face="sans-serif">When I run into issues like this I typically create a table with all varchar fields and load into that table to check if what I'm loading into the columns is what I expected to. Often it's not and adjustments need to be made in the control file.</font> <br> <br><font size=2 face="sans-serif">I also prefer external tables - just preference. I create the external table as varchars and then do the manipulation on the fields during the select from the external.</font> <br> <br><font size=2 face="Courier New">rbld=`$SQL >> $OUT_FILE << !REBUILD</font> <br> <br><font size=2 face="Courier New"> create directory $BASE_DIR_NAME as '$BASE_DIR';</font> <br><font size=2 face="Courier New"> create directory $LOG_DIR_NAME as '$LOG_DIR';</font> <br> <br><font size=2 face="Courier New"> grant read,write on directory $BASE_DIR_NAME to $OWNER, bwisniewski;</font> <br><font size=2 face="Courier New"> grant read,write on directory $LOG_DIR_NAME to $OWNER, bwisniewski;</font> <br> <br><font size=2 face="Courier New"> create table $EXT_TABLE</font> <br><font size=2 face="Courier New"> (BAN varchar2(9),</font> <br><font size=2 face="Courier New"> NAME varchar2(20),</font> <br><font size=2 face="Courier New"> ADDRESS varchar2(25),</font> <br><font size=2 face="Courier New"> CITY varchar2(12),</font> <br><font size=2 face="Courier New"> STATE varchar2(2),</font> <br><font size=2 face="Courier New"> ZIP varchar2(5),</font> <br><font size=2 face="Courier New"> SUBSCRIBER varchar2(10),</font> <br><font size=2 face="Courier New"> BALANCE varchar2(8))</font> <br><font size=2 face="Courier New"> organization external</font> <br><font size=2 face="Courier New"> (type oracle_loader</font> <br><font size=2 face="Courier New"> default directory $BASE_DIR_NAME</font> <br><font size=2 face="Courier New"> access parameters</font> <br><font size=2 face="Courier New"> (records fixed 99 delimited by newline</font> <br><font size=2 face="Courier New"> badfile $LOG_DIR_NAME:'$BAD_FILE'</font> <br><font size=2 face="Courier New"> logfile $LOG_DIR_NAME:'$LOG_FILE'</font> <br><font size=2 face="Courier New"> discardfile $LOG_DIR_NAME:'$DIS_FILE'</font> <br><font size=2 face="Courier New"> load when (ban notequal blanks and subscriber notequal blanks)</font> <br><font size=2 face="Courier New"> fields lrtrim(</font> <br><font size=2 face="Courier New"> BAN (1:+9),</font> <br><font size=2 face="Courier New"> NAME (*:+20),</font> <br><font size=2 face="Courier New"> ADDRESS (*:+25),</font> <br><font size=2 face="Courier New"> CITY (*:+12),</font> <br><font size=2 face="Courier New"> STATE (*:+2),</font> <br><font size=2 face="Courier New"> ZIP (*:+5),</font> <br><font size=2 face="Courier New"> SUBSCRIBER (*:+10),</font> <br><font size=2 face="Courier New"> BALANCE (*:+8)))</font> <br><font size=2 face="Courier New"> location ($BASE_DIR_NAME:'$FTP_FILE'))</font> <br><font size=2 face="Courier New"> reject limit unlimited;</font> <br> <br><font size=2 face="Courier New">!REBUILD`</font> <br> <br><font size=2 face="sans-serif">...</font> <br> <br><font size=2 face="sans-serif">This is where I do the formatting and conversion to a number..</font> <br> <br><font size=2 face="Courier New"> insert into $TABLE (ban, name, address, city, state, zip, subscriber, balance)</font> <br><font size=2 face="Courier New"> select ban, name, address, city, state, zip, subscriber, to_number(ltrim(balance,'0'))/100 </font> <br><font size=2 face="Courier New"> from $EXT_TABLE;</font> <br> <br><font size=2 face="sans-serif">- Brian</font> <br> <br> <br> <br> <br> <table width=100%> <tr valign=top> <td> <td><font size=1 face="sans-serif"><b>Madhavi Kanugo <MKanugo@(protected)> </b></font> <br><font size=1 face="sans-serif">Sent by: oracle-l-bounce@(protected)</font> <p><font size=1 face="sans-serif">12/07/2005 01:19 PM</font> <br><font size=1 face="sans-serif">Please respond to MKanugo</font> <td><font size=1 face="Arial"> </font> <br><font size=1 face="sans-serif"> To: "'oracle-l@(protected)'" <oracle-l@(protected)></font> <br><font size=1 face="sans-serif"> cc: </font> <br><font size=1 face="sans-serif"> Subject: SQL*Loader Date error (ORA-01858 (See ORA-01858.ora-code.com ))</font></table> <br> <br> <br><font size=2 face="Arial">Hello All,</font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial">I'm trying to load data using SQL Loader and ran into the ORA-01858 (See ORA-01858.ora-code.com ): </font><font size=3 face="Times New Roman">a non-numeric character was found where a numeric was expected </font><font size=2 face="Arial">error.</font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial">Below is my control file. As you can see, the timestamp is a constant field and I am loading its value from the filename of the data files. I am executing the sql loader from a shell script and creating the control file on the fly. The filename is in the form of: 20051206130101.txt So basically, the shell script replaces the when_changed value with 20051206130101.</font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial">I created a temp table with just a date field and tried to insert a value into it. Insert into temp values (</font><font size =2 face="Courier">to_date</font><font size=2 color=#0000f0 face="Courier">(< /font><font size=2 color=red face="Courier">'20051207160752'</font><font size=2 color=#0000f0 face="Courier">,</font><font size=2 color=red face="Courier"> 'YYYYMMDDHH24MISS'</font><font size=2 color=#0000f0 face="Courier">)); and there is no error and date conversion is implict.</font> <br><font size=2 color=#0000f0 face="Courier"> </font> <br><font size=2 color=#0000f0 face="Courier">But SQLLOADER is erring out on ORA-01858 (See ORA-01858.ora-code.com ). </font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial">LOAD DATA </font> <br><font size=2 face="Arial">INFILE FILENAME </font> <br><font size=2 face="Arial">APPEND </font> <br><font size=2 face="Arial">INTO TABLE RE_STATS_STAGING</font> <br><font size=2 face="Arial">FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' </font> <br><font size=2 face="Arial"> TRAILING NULLCOLS </font> <br><font size=2 face="Arial">( </font> <br><font size=2 face="Arial"> RE_NAME,</font> <br><font size=2 face="Arial"> TG_TYPE,</font> <br><font size=2 face="Arial"> TRUNKGROUP,</font> <br><font size=2 face="Arial"> CONNECTS,</font> <br><font size=2 face="Arial"> HANGUPS,</font> <br><font size=2 face="Arial"> DECLINES,</font> <br><font size=2 face="Arial"> LOOPS,</font> <br><font size=2 face="Arial"> SECONDS,</font> <br><font size=2 face="Arial"> CC_CONNECTED,</font> <br><font size=2 face="Arial"> CC_SETUP,</font> <br><font size=2 face="Arial"> TIMESTAMP CONSTANT "to_date('_when_changed_','YYYYMMDDHH24MISS')"< /font> <br><font size=2 face="Arial"> )</font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial">Any ideas on where I am going wrong? Any thoughts or help will be appreciated.</font> <br><font size=2 face="Arial"><br> Thanks in advance,</font> <br><font size=2 face="Arial">Madhavi</font> <br><font size=2 face="Arial"> </font> <br><font size=3 face="Times New Roman"> </font> <br>