Home » RDBMS Server » Server Utilities » Last terminator missing: any workaround?
Last terminator missing: any workaround? [message #157242] Wed, 01 February 2006 04:33 Go to next message
bobo69
Messages: 9
Registered: November 2005
Junior Member
Hi,

Despite Oracle10 documentation, if the last field has no terminator and is numeric, there is an error at loading time even using Oracle's example:
CREATE TABLE emp_load (first_name CHAR(15), last_name CHAR(20), year_of_birth INT)
ORGANIZATION EXTERNAL (TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab_dir
ACCESS PARAMETERS (FIELDS TERMINATED BY ","
MISSING FIELD VALUES ARE NULL)
LOCATION ('info.dat'));

Alvin,Tolliver,1976
Baer,Kenneth
Mary,Dube,1973

I get:
FIRST_NAME CHAR (255)
Terminated by ","
Trim whitespace same as SQL Loader
LAST_NAME CHAR (255)
Terminated by ","
Trim whitespace same as SQL Loader
YEAR_OF_BIRTH CHAR (255)
Terminated by ","
Trim whitespace same as SQL Loader
error processing column YEAR_OF_BIRTH in row 1 for datafile /PROJET/AESLAB/bin/scripts/PC201/yeast/foo.dat
ORA-01722: invalid number
error processing column YEAR_OF_BIRTH in row 3 for datafile /PROJET/AESLAB/bin/scripts/PC201/yeast/foo.dat
ORA-01722: invalid number


Other examples work because the year is considered as CHAR.
If the last field is a string, no problem, by indicating its length, it loads.
Has anyone had the same problem? I will hardly convince the provider to add a terminator.
Thanks for any hint!
Re: Last terminator missing: any workaround? [message #157348 is a reply to message #157242] Wed, 01 February 2006 17:52 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9097
Registered: November 2002
Location: California, USA
Senior Member
It works for me in 9i, as shown below. So, perhaps it is a 10g bug or perhaps you have invisible control characters that prevent it front being read as a number. What happens if you change the dataype to varchar2, then try to:

select to_number (year_of_birth) from emp_load;

scott@ORA92> CREATE OR REPLACE DIRECTORY ext_tab_dir AS 'c:\oracle'
  2  /

Directory created.

scott@ORA92> CREATE TABLE emp_load
  2    (first_name    CHAR(15),
  3  	last_name     CHAR(20),
  4  	year_of_birth INT)
  5    ORGANIZATION EXTERNAL
  6  	 (TYPE ORACLE_LOADER
  7  	  DEFAULT DIRECTORY ext_tab_dir
  8  	  ACCESS PARAMETERS
  9  	    (FIELDS TERMINATED BY ","
 10  	     MISSING FIELD VALUES ARE NULL)
 11  	  LOCATION ('info.dat'))
 12  /

Table created.

scott@ORA92> SELECT * FROM emp_load
  2  /

FIRST_NAME      LAST_NAME            YEAR_OF_BIRTH
--------------- -------------------- -------------
Alvin           Tolliver                      1976
Baer            Kenneth
Mary            Dube                          1973

scott@ORA92>

Re: Last terminator missing: any workaround? [message #157377 is a reply to message #157348] Thu, 02 February 2006 01:16 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
You don't have DOS carriage returns at the end of line do you?
Re: Last terminator missing: any workaround? [message #157395 is a reply to message #157348] Thu, 02 February 2006 02:58 Go to previous message
bobo69
Messages: 9
Registered: November 2005
Junior Member
Barbara -
Thanks, that's what I had in mind, in case nothing else works, yes.

rleishman -
Using the oracle example, I created the foo.dat (or info.dat) using my PC windows platform, so I have '^M' (DOS like? I don't know, may be) at each end of line (that's what the vi editor shows me, once copied on the unix platform). So I could perhaps do it differently, and avoiding these extra characters , but my real-life files are generated on windows platforms, so anyway I have to deal with these end-of-line characters.
I'll probably use a Barbara-like solution and convert.
I still did not give up the effort to convince the providers to add a final field terminator, let's see ...
Thanks anyways!
Previous Topic: SQL*Loader won't load text over a certain length
Next Topic: export to tape
Goto Forum:
  


Current Time: Tue Jul 02 04:33:31 CDT 2024