Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

External table definition. Can you use SUBSTR( ) ?

chuckersFeb 22 2010 — edited Feb 23 2010
We have an unconvential input file. It looks something like the following, with 3 columns
123456 This is a description STATIC
123457 This is a different description DYNAMIC
123457 And even another description BOTH
The problem lies in the fact that spaces separate the columns, as well as exist in the 'description'.

Now, it's easy enough to just pull in the data as one column in an EXTERNAL TABLE, and then run a SUBSTR( ) against the data to pull everything apart, but that means either a VIEW, or some PL/SQL.

Is there anyway to add something like the following into the EXTERNAL TABLE def'n itself?

COL1 = SUBSTR(row, 1, first space)
COL2 = SUBSTR(row, first space + 1, position of last space - position of first space - 1)
COL3 = SUBSTR(row, last space + 1)


I can write this pseudocode as proper SQL, but I don't know how to add it to the table def'n. Alll the examples I've seen so far format incoming date data, like
...
ORGANIZATION EXTERNAL
  (  TYPE ORACLE_LOADER
     DEFAULT DIRECTORY EDS_DATA_DIR
     ACCESS PARAMETERS 
       ( records delimited by newline 
	  nobadfile nologfile nodiscardfile 
	  fields terminated by '|' 
	  missing field values are null 
	  reject rows with all null fields 
	  ( 
		TK, 
		CIT_NO, 
		CONTEST_DT  DATE "YYYY/MM/DD" 
		   NULLIF ( CONTEST_DT = BLANKS ), 
...
but nothing resembles what I need.

Thanks,
--=Chuck
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 23 2010
Added on Feb 22 2010
4 comments
3,527 views