Position in external table

We have excel spread sheet.
We wanted to load data from excel spread sheet to Oracle via external table.
I saved my file into .txt format.
No I need to create external table in oracle DB.
my question is as follows:
Do I need to define exact lenght of datatype per data?
Now data of column city take 16 slots in data file.
But I defined size 30, is it ok?
SQL>CREATE TABLE External_City
CITY VARCHAR2(30),
STATE VARCHAR2(20),
ZIP VARCHAR2(10),
COUNTRY VARCHAR2(30)
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY DATALOAD
ACCESS PARAMETERS
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ‘,’
MISSING FIELD VALUES ARE NULL
LOCATION (’city_comma.txt’)
REJECT LIMIT UNLIMITED;
Do we need to define data position in external table?

I do not think it has to do with your data or positon of data in it. I am not sure what or where your file is. You need to ensure accessibility to it. it is not seeing the file at all.
BTW - avoid using udump location as your directory location. Change the directory location (I am not saying it is the cause).
Here is my test. Although my class.dat file is empty, it shows that your external table should work once your file and directory is accessible. I have only replaced DATALOAD with mytest_dir
testdb@DBMSDIRECT01:/export/home/oracle/dbmsdirect/test:touch class.dat
testdb@DBMSDIRECT01:/export/home/oracle/dbmsdirect/test:sqlplus /nolog
SQL*Plus: Release 10.2.0.2.0 - Production on Mon May 19 15:34:55 2008
Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
SQL> connect testuser
Enter password:
Connected.
SQL> create or replace directory mytest_dir as '/export/home/oracle/dbmsdirect/test';
Directory created.
SQL>
SQL>
SQL> create table external_class
  2  (
  3  item_no number(10),
  4  class varchar2(255),
  5  level_date date,
  6  note varchar2(4),
  7  sched_level varchar2(10),
  8  min_range number(12),
  9  max_range number(14)
10  )
11  ORGANIZATION EXTERNAL
12  (
13  TYPE oracle_loader
14  DEFAULT DIRECTORY mytest_dir
15  ACCESS PARAMETERS (
16  RECORDS DELIMITED BY NEWLINE
17  FIELDS TERMINATED BY ','
18  MISSING FIELD VALUES ARE NULL
19  REJECT ROWS WITH ALL NULL FIELDS
20  (item_no, class, level_date, note,sched_level,min_range,max_range)
21  )
22  LOCATION ('class.dat')
23  )
24  PARALLEL
REJECT LIMIT 0;
25
Table created.
SQL> desc external_class
Name                                      Null?    Type
ITEM_NO                                            NUMBER(10)
CLASS                                              VARCHAR2(255)
LEVEL_DATE                                         DATE
NOTE                                               VARCHAR2(4)
SCHED_LEVEL                                        VARCHAR2(10)
MIN_RANGE                                          NUMBER(12)
MAX_RANGE                                          NUMBER(14)
SQL>
SQL> select * from external_class;
no rows selected
SQL>
SQL> ho rm class.dat
SQL>
SQL> select * from external_class;
select * from external_class
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file class.dat in MYTEST_DIR not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19
SQL>
SQL> ho touch class.dat
SQL>
SQL> select * from external_class;
no rows selected
SQL>
SQL>
SQL> col DIRECTORY_PATH format a50
SQL> set lines 200
SQL> select * from dba_directories where DIRECTORY_NAME = 'MYTEST_DIR';
OWNER                          DIRECTORY_NAME                 DIRECTORY_PATH
SYS                            MYTEST_DIR                     /export/home/oracle/dbmsdirect/test
SQL>

Similar Messages

  • Error: while Selecting External table

    Hi everybody,
    When i Select an external table i am getting this error. The file is like this:
    229|1|506460|SIGROUP |4890|100|0|0|10:31:01|2007/12/17|M009|20191395001|L|B|12|CLIENT|INE547A01012|10:31:00|
    229|1|506460|SIGROUP |4900|900|0|0|10:31:01|2007/12/17|M009|20191395001|L|B|13|CLIENT|INE547A01012|10:31:00|
    229|1|500407|SWARAJENG |21400|300|0|0|10:33:28|2007/12/17|OWN|20191397001|L|B|154|OWN|INE277A01016|10:33:28|
    I had created the Table like this:
    SQL> CREATE TABLE TEMP_SAUDA
    2 (S_A VARCHAR2(20),
    3 S_TYPE VARCHAR2(20),
    4 S_CO VARCHAR2(20),
    5 S_CONAME VARCHAR2(40),
    6 S_RATE NUMBER,
    7 S_QTY NUMBER,
    8 S_G NUMBER,
    9 S_H NUMBER,
    10 S_TIME TIMESTAMP WITH TIME ZONE,
    11 S_DATE DATE,
    12 S_PCODE VARCHAR2(20),
    13 S_SETNO VARCHAR2(20),
    14 S_M VARCHAR2(20),
    15 S_N VARCHAR2(20),
    16 S_O VARCHAR2(20),
    17 S_CLIENTOWN VARCHAR2(10),
    18 S_ISIN VARCHAR2(12),
    19 S_ORDER_TIME TIMESTAMP WITH TIME ZONE
    20 )
    21 ORGANIZATION EXTERNAL
    22 (TYPE oracle_loader
    23 DEFAULT DIRECTORY BSE17122007
    24 ACCESS PARAMETERS
    25 (RECORDS DELIMITED BY NEWLINE
    26 FIELDS
    27 (
    28 S_A CHAR(20),
    29 S_TYPE CHAR(20),
    30 S_CO CHAR(20),
    31 S_CONAME CHAR(20),
    32 S_RATE CHAR(20),
    33 S_QTY CHAR(20),
    34 S_G CHAR(20),
    35 S_H CHAR(20),
    36 S_TIME CHAR(35) date_format TIMESTAMP WITH TIMEZONE mask "DD-MON-RR HH.MI.SSXFF AM TZH:TZM
    37 S_DATE CHAR(22) date_format DATE mask "mm/dd/yyyy hh:mi:ss ",
    38 S_PCODE CHAR(20),
    39 S_SETNO CHAR(20),
    40 S_M CHAR(20),
    41 S_N CHAR(20),
    42 S_O CHAR(20),
    43 S_CLIENTOWN CHAR(20),
    44 S_ISIN CHAR(20),
    45 S_ORDER_TIME date_format TIMESTAMP WITH TIMEZONE mask "DD-MON-RR HH.MI.SSXFF AM TZH:TZM"
    46 )
    47 )
    48 location (BSE17122007:'BR171207.DAT')
    49 )
    50 ;
    Table created.
    SQL> SELECT * FROM TEMP_SAUDA;
    SELECT * FROM TEMP_SAUDA
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "date_format": expecting one of: "binary_double,
    binary_float, comma, char, date, defaultif, decimal, double, float, integer, (,
    nullif, oracle_date, oracle_number, position, raw, recnum, ), unsigned,
    varrawc, varchar, varraw, varcharc, zoned"
    KUP-01007: at line 21 column 14
    ORA-06512: at "SYS.ORACLE_LOADER", line 19
    Is there any mistake in this table creation.
    what i have to declare to the time format if the format in the file id hh:mm:ss
    Thank u...!
    Ravi

    The output you posted is completely wrong, I could not even create the table without errors.
    Try with this.
    CREATE TABLE TEMP_SAUDA
    (S_A VARCHAR2(20),
    S_TYPE VARCHAR2(20),
    S_CO VARCHAR2(20),
    S_CONAME VARCHAR2(40),
    S_RATE NUMBER,
    S_QTY NUMBER,
    S_G NUMBER,
    S_H NUMBER,
    S_TIME TIMESTAMP WITH TIME ZONE,
    S_DATE DATE,
    S_PCODE VARCHAR2(20),
    S_SETNO VARCHAR2(20),
    S_M VARCHAR2(20),
    S_N VARCHAR2(20),
    S_O VARCHAR2(20),
    S_CLIENTOWN VARCHAR2(10),
    S_ISIN VARCHAR2(12),
    S_ORDER_TIME TIMESTAMP WITH TIME ZONE
    ORGANIZATION EXTERNAL
    (TYPE oracle_loader
    DEFAULT DIRECTORY BSE17122007
    ACCESS PARAMETERS
    (RECORDS DELIMITED BY NEWLINE
    FIELDS terminated by "|"
    S_A CHAR(20),
    S_TYPE CHAR(20),
    S_CO CHAR(20),
    S_CONAME CHAR(20),
    S_RATE CHAR(20),
    S_QTY CHAR(20),
    S_G CHAR(20),
    S_H CHAR(20),
    S_TIME CHAR(8) date_format TIMESTAMP WITH TIMEZONE mask "HH.MI.SSXFF AM TZH:TZM",
    S_DATE CHAR(10) date_format DATE mask "yyyy/mm/dd",
    S_PCODE CHAR(20),
    S_SETNO CHAR(20),
    S_M CHAR(20),
    S_N CHAR(20),
    S_O CHAR(20),
    S_CLIENTOWN CHAR(20),
    S_ISIN CHAR(20),
    S_ORDER_TIME char(8) date_format TIMESTAMP WITH TIMEZONE mask "HH.MI.SSXFF AM TZH:TZM"
    location (BSE17122007:'BR171207.DAT')
    ;With this you get:
    SQL> col s_time format a40
    SQL> col s_date format a40
    SQL> col s_order_time format a40
    SQL> r
      1* select s_time,s_date,s_order_time from temp_sauda
    S_TIME                                   S_DATE                                   S_ORDER_TIME
    01-JAN-08 10.31.01.000000 AM +00:00      17.DEC.2007 00:00:00                     01-JAN-08 10.31.00.000000 AM +00:00
    01-JAN-08 10.31.01.000000 AM +00:00      17.DEC.2007 00:00:00                     01-JAN-08 10.31.00.000000 AM +00:00
    01-JAN-08 10.33.28.000000 AM +00:00      17.DEC.2007 00:00:00                     01-JAN-08 10.33.28.000000 AM +00:00Be aware that your file does not contain date information for the time fields, so as you see above it is defaulted to 01-JAN-08 for the S_TIME and S_ORDER_TIME column.

  • External table - fetch location ?

    Using Oracle 10.2.0.5
    An external table is a construct that gives me SQL access to a file.
    Is it possible to know the name of the file somehow inside the select? Like Add a column with the file name?
    pseudo example
    CREATE TABLE EXT_DUMMY
        "RECORDTYPE" VARCHAR2(100 BYTE),
        "COL1" VARCHAR2(100 BYTE),
        "COL2" VARCHAR2(100 BYTE),
        "FILE" VARCHAR2(100 BYTE)
    ORGANIZATION EXTERNAL
        TYPE ORACLE_LOADER DEFAULT DIRECTORY "IMPORT_BAD_FILE"
        ACCESS PARAMETERS (
                 records delimited BY newline
                 FIELDS TERMINATED BY ';'
                 MISSING FIELD VALUES ARE NULL
                   ( RECORDTYPE CHAR
                   , COL1 CHAR
                   , COL2 CHAR
                   , FILE CHAR FILLER
        LOCATION ( 'Testfile1.txt, Testfile2.txt' )
        reject limit 10
    ;The result could look like this:
    RECORDTYPE   COL1       COL2      FILE
    SAMPLE           DUMMY    DUMMY Testfile1.txt
    SAMPLE           DUMMY1   DUMMY Testfile1.txt
    SAMPLE           DUMMY2   DUMMY Testfile1.txt
    SAMPLE           DUMMY3   DUMMY Testfile1.txt
    SAMPLE           DUMMY1   DUMMY1 Testfile2.txt
    SAMPLE           DUMMY1   DUMMY2 Testfile2.txt
    SAMPLE           DUMMY2   DUMMY1 Testfile2.txtI would like to know from which file a certain row is read. Maybe I missed an option in the documentation. In this example I have two different files as the source for the external table.
    Another use case could be this:
    If I enable a user to switch the external table to a different file alter table EXT_DUMMY location ('Testfile3.txt' ). How can we know which file is read during the select on the table? When userA does the select, maybe userB just altered the location before the select was started. Therefore userA would read in a different file then expected.
    Edited by: Sven W. on May 26, 2011 4:48 PM
    Edited by: Sven W. on May 26, 2011 4:51 PM
    Edited by: Sven W. on May 26, 2011 5:11 PM

    Hi Sven,
    I'm not sure how much we can rely on this, but let's consider the following :
    create table test_xt (
      rec_id  number
    , message varchar2(100)
    organization external (
      default directory test_dir
      access parameters (
        records delimited by newline
        fields terminated by ';'
      location (
        'marc5.txt'
      , 'test1.csv'
      , 'test2.csv'
      , 'test3.csv'
    );I always thought the ROWID doesn't hold much sense for an external table, but...
    SQL> select t.rowid
      2       , dump(t.rowid) as rowid_dump
      3       , regexp_substr(dump(t.rowid,10,9,1),'\d+$') as file#
      4       , t.*
      5  from test_xt t
      6  ;
    ROWID              ROWID_DUMP                                                FILE#      REC_ID MESSAGE
    (AADVyAAAAAAAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,0,0,0,0,0,0,0,0,0     0               1 this is a line from marc5.txt
    (AADVyAAAAAAAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,0,0,0,0,0,0,0,0,33    0               2 this is a line from marc5.txt
    (AADVyAAAAAAAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,0,0,0,0,0,0,0,0,66    0               3 this is a line from marc5.txt
    (AADVyAAAAAAAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,0,0,0,0,0,0,0,0,99    0               4 this is a line from marc5.txt
    (AADVyAAAAAEAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,1,0,0,0,0,0,0,0,0     1               1 this is a line from test1.csv
    (AADVyAAAAAEAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,1,0,0,0,0,0,0,0,33    1               2 this is a line from test1.csv
    (AADVyAAAAAEAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,1,0,0,0,0,0,0,0,66    1               3 this is a line from test1.csv
    (AADVyAAAAAEAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,1,0,0,0,0,0,0,0,99    1               4 this is a line from test1.csv
    (AADVyAAAAAIAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,2,0,0,0,0,0,0,0,0     2               1 this is a line from test2.csv
    (AADVyAAAAAIAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,2,0,0,0,0,0,0,0,33    2               2 this is a line from test2.csv
    (AADVyAAAAAIAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,2,0,0,0,0,0,0,0,66    2               3 this is a line from test2.csv
    (AADVyAAAAAMAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,3,0,0,0,0,0,0,0,0     3               1 this is a line from test3.csv
    (AADVyAAAAAMAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,3,0,0,0,0,0,0,0,33    3               2 this is a line from test3.csv
    (AADVyAAAAAMAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,3,0,0,0,0,0,0,0,66    3               3 this is a line from test3.csv
    (AADVyAAAAAMAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,3,0,0,0,0,0,0,0,99    3               4 this is a line from test3.csv
    (AADVyAAAAAMAAAAAA Typ=208 Len=17: 4,0,0,213,200,0,0,0,3,0,0,0,0,0,0,0,132   3               5 this is a line from test3.csv
    16 rows selected
    Then with a join to EXTERNAL_LOCATION$ :
    SQL> with ext_loc as (
      2    select position-1 as pos
      3         , name as filename
      4    from sys.external_location$
      5    where obj# = ( select object_id
      6                   from user_objects
      7                   where object_name = 'TEST_XT' )
      8  )
      9  select x.filename,
    10         t.*
    11  from test_xt t
    12       join ext_loc x on x.pos = to_number(regexp_substr(dump(t.rowid,10,9,1),'\d+$'))
    13  ;
    FILENAME       REC_ID MESSAGE
    marc5.txt           1 this is a line from marc5.txt
    marc5.txt           2 this is a line from marc5.txt
    marc5.txt           3 this is a line from marc5.txt
    marc5.txt           4 this is a line from marc5.txt
    test1.csv           1 this is a line from test1.csv
    test1.csv           2 this is a line from test1.csv
    test1.csv           3 this is a line from test1.csv
    test1.csv           4 this is a line from test1.csv
    test2.csv           1 this is a line from test2.csv
    test2.csv           2 this is a line from test2.csv
    test2.csv           3 this is a line from test2.csv
    test3.csv           1 this is a line from test3.csv
    test3.csv           2 this is a line from test3.csv
    test3.csv           3 this is a line from test3.csv
    test3.csv           4 this is a line from test3.csv
    test3.csv           5 this is a line from test3.csv
    Seems to work... assuming the files are always read in the order specified through the LOCATION parameter, and the generated ROWID actually means what I think it means.

  • External table: How to load data from a fixed format UTF8 external file

    Hi Experts,
    I am trying to read data from a fixed format UTF8 external file in to a external table. The file has non-ascii characters, and the presence of the non-ascii characters causes the data to be positioned incorrectly in the external table.
    The following is the content's of the file:
    20100423094529000000I1 ABÄCDE 1 000004
    20100423094529000000I2 OMS Crew 2 2 000004
    20100423094529000000I3 OMS Crew 3 3 000004
    20100423094529000000I4 OMS Crew 4 4 000004
    20100423094529000000I5 OMS Crew 5 5 000004
    20100423094529000000I6 OMS Crew 6 6 000004
    20100423094529000000I7 Mobile Crew 7 7 000004
    20100423094529000000I8 Mobile Crew 8 8 000004
    The structure of the data is as follows:
    Name Type Start End Length
    UPDATE_DTTM CHAR 1 20 20
    CHANGE_TYPE_CD CHAR 21 21 1
    CREW_CD CHAR 22 37 16
    CREW_DESCR CHAR 38 97 60
    CREW_ID CHAR 98 113 16
    UDF1_CD CHAR 114 143 30
    UDF1_DESCR CHAR 144 203 60
    UDF2_CD CHAR 204 233 30
    DATA_SOURCE_IND CHAR 294 299 6
    UDF2_DESCR CHAR 234 293 60
    I create the external table as follows:
    CREATE TABLE "D_CREW_EXT"
    "UPDATE_DTTM" CHAR(20 BYTE),
    "CHANGE_TYPE_CD" CHAR(1 BYTE),
    "CREW_CD" CHAR(16 BYTE),
    "CREW_DESCR" CHAR(60 BYTE),
    "CREW_ID" CHAR(16 BYTE),
    "UDF1_CD" CHAR(30 BYTE),
    "UDF1_DESCR" CHAR(60 BYTE),
    "UDF2_CD" CHAR(30 BYTE),
    "DATA_SOURCE_IND" CHAR(6 BYTE),
    "UDF2_DESCR" CHAR(60 BYTE)
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER DEFAULT DIRECTORY "TMP"
    ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE
    CHARACTERSET UTF8
    STRING SIZES ARE IN BYTES
    NOBADFILE NODISCARDFILE NOLOGFILE FIELDS NOTRIM
    ( "UPDATE_DTTM" POSITION (1:20) CHAR(20),
    "CHANGE_TYPE_CD" POSITION (21:21) CHAR(1),
    "CREW_CD" POSITION (22:37) CHAR(16),
    "CREW_DESCR" POSITION (38:97) CHAR(60),
    "CREW_ID" POSITION (98:113) CHAR(16),
    "UDF1_CD" POSITION (114:143) CHAR(30),
    "UDF1_DESCR" POSITION (144:203) CHAR(60),
    "UDF2_CD" POSITION (204:233) CHAR(30),
    "DATA_SOURCE_IND" POSITION (294:299) CHAR(6),
    "UDF2_DESCR" POSITION (234:293) CHAR(60) )
    ) LOCATION ( 'D_CREW_EXT.DAT' )
    REJECT LIMIT UNLIMITED;
    Check the result in database:
    select * from D_CREW_EXT;
    I found the first row is incorrect. For each non-ascii character,the fields to the right of the non-ascii character are off by 1 character,meaning that the data is moved 1 character to the right.
    Then I tried to use the option STRING SIZES ARE IN CHARACTERS instead of STRING SIZES ARE IN BYTES, it doesn't work either.
    The database version is 11.1.0.6.
    Edited by: yuan on May 21, 2010 2:43 AM

    Hi,
    I changed the BYTE in the create table part to CHAR, it still doesn't work. The result is the same. I think the problem is in ACCESS PARAMETERS.
    Any other suggestion?

  • Error while using External Table

    Hi Guru's,
    I am using external tables in my procedure and the code to create it will be dynamically built inside the procedure itself. I have tested it so many times and it works fine only. But suddenly now it is throwing some error and i was not able to figure out the problem.
    Additional Info:
    1. I have provided the full rights to the input directory.
    2. Working in Oracle 10g release 2
    3. Unix OS in server
    4. Error description:
    << UK_TRADINGDATA_LOAD >> ABEND : <<ABEND SYS-000 >> uncatched ORACLE-error : ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04040: file EXTRACTION COMPLETED in EXT_UK_TRADINGDATA not found
               v_ac_sql:='CREATE TABLE VLDPROCESS'||gv_ac_schema_suffix||'.EXT_UK_TRAD_'||gv_ac_machineid ||'_'||gv_ac_retailer_id||'_ADHOC'||CHR(10)
                            ||'(  AC_RETAILER_ID       VARCHAR2(2 BYTE),'||CHR(10)
                            ||'AC_DEPARTMENT_CD     VARCHAR2(20 BYTE),'||CHR(10)
                            ||'NC_PERIOD_FROM       NUMBER,'||CHR(10)
                            ||'NC_PERIOD_TO       NUMBER'||CHR(10)   
                            ||')'||CHR(10)
                            ||'ORGANIZATION EXTERNAL'||CHR(10)
                            ||'(TYPE ORACLE_LOADER'||CHR(10)
                            ||'DEFAULT DIRECTORY EXT_UK_TRADINGDATA'||CHR(10)
                            ||'ACCESS PARAMETERS'||CHR(10)
                            ||'(RECORDS DELIMITED BY NEWLINE'||CHR(10)
                            ||'badfile     '''||v_ac_failed_files||'.bad'''||CHR(10)
                            ||'discardfile '''||v_ac_failed_files||'.dis'''||CHR(10)
                            ||'logfile     '''||v_ac_failed_files||'.log'''||CHR(10)
                            ||'FIELDS'||CHR(10)
                            ||'('||CHR(10)
                            ||'AC_RETAILER_ID   position( 1: 2) char( 2),'||CHR(10)
                            ||'AC_DEPARTMENT_CD position( 3:22) char(20),'||CHR(10)
                            ||'NC_PERIOD_FROM   position(23:29) char( 7),'||CHR(10)
                            ||'NC_PERIOD_TO     position(30:36) char( 7)'||CHR(10)     
                            ||')'||CHR(10)
                            ||')'||CHR(10)
                            ||'LOCATION ('''||v_ac_file_name ||''')'||CHR(10)
                            ||')'||CHR(10)
                            ||'REJECT LIMIT 100'||CHR(10)
                            ||'NOPARALLEL'||CHR(10)
                            ||'NOMONITORING';  
               EXECUTE IMMEDIATE v_ac_sql; Kindly help me!
    With Regards,
    VJ

    Sometimes when troubleshooting issues like this it is helpful to output the dynamic SQL generated to the screen or spool it to a text file. From there it's usually easy to determine where the problem lies.
    If you can provide that one of the forum members can figure it out.

  • External Table Error

    While Creating an external table I got following error
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "missing": expecting one of: "badfile, byteordermark, characterset, column, data, delimited, discardfile, disable_directory_link_check, exit, fields, fixed, load, logfile, language, nodiscardfile, nobadfile, nologfile, date_cache, processing, readsize, string, skip, territory, varia¿gÀ"
    KUP-01007: at line 2 column 14
    ORA-06512: at
    My CREATE TABLE Syntax is as follow
    CREATE TABLE APPL_NOTE_EXT
    CUS_ID NUMBER(10),
    TEXT VARCHAR2(2000 ),
    PAGE_NUM NUMBER(3)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY EXT_TABLE
    ACCESS PARAMETERS
    RECORDS DELIMITED BY newline
    MISSING FIELD VALUES ARE NULL
    FIELDS
    CUS_ID POSITION (2:10) ,
    TEXT POSITION (39:1737),
    PAGE_NUM POSITION (13:14)
    LOCATION ('APPNOTES.TXT')
    REJECT LIMIT Unlimited
    NOPARALLEL
    NOMONITORING;

    This is the result I obtained after creating the table with your script:
    Table created.
    SQL> desc APPL_NOTE_EXT
    Name                                      Null?    Type
    CUS_ID                                             NUMBER(10)
    TEXT                                               VARCHAR2(2000)
    PAGE_NUM                                           NUMBER(3)The only issue I faced was the directory object. I had to create it. May be you don't have privileges on the specified ext_table directory. Please verify.
    ~ Madrid

  • Error when i fetch the external table in oracle 9i ?

    External table is created.
    But, when i select the external table , it is thrwing the following error.
    I have given READ and WRITE permission to the oracle directory.
    And, i having the flat file with comma delimited data.
    SQL> create table mohan_ext (
    2 EMPNO NUMBER(5) ,
    3 JOB VARCHAR2(15),
    4 SALARY NUMBER(8,2),
    5 MGR NUMBER(5) ,
    6 HIREDATE DATE,
    7 DEPTNO NUMBER(5)
    8 )
    9 organization external
    10 (type oracle_loader
    11 default directory ext_dir
    12 access parameters (records delimited by newline
    13 fields terminated by ','
    14 missing field values are null
    15 (
    16 EMPNO NUMBER(5:5) ,
    17 JOB VARCHAR2(15:15),
    18 SALARY NUMBER(8,2:8,2),
    19 MGR NUMBER(5:5) ,
    20 HIREDATE DATE,
    21 DEPTNO NUMBER(5:5)
    22 )
    23 )
    24 LOCATION('flat.txt'));
    Table created.
    SQL> select * from mohan_ext;
    select * from mohan_ext
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "identifier": expecting one of: "comma, char, date, defaultif,
    decimal, double, float, integer, (, nullif, oracle_date, oracle_number, position, raw, recnum, ),
    unsigned, varrawc, varchar, varraw, varcharc, zoned"
    KUP-01008: the bad identifier was: NUMBER
    KUP-01007: at line 5 column 11
    ORA-06512: at "SYS.ORACLE_LOADER", line 14
    ORA-06512: at line 1
    SQL>

    You may need to scrub some of the data prior to using it as an external table. For instance, ensure that you do not have any extra commas lingering around somewhere within the data as this could cause mapping issues with the data. I've used this process hundreds of times, and more often than not there is an extra comma somewhere that is causing the issue.

  • Error:loading from external table to database table

    hi,
    Following error comes while inserting data from external to new_ext table
    what might be the reason??
    error and external table creation script is as follows
    regards,
    Avinash
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEFETCH callout
    ORA-29400: data cartridge error
    KUP-04020: found record longer than buffer size supported, 524288, in
    /home/oracle/rgtr1.txt
    ORA-06512: at " SYS.ORACLE_LOADER", line 14
    ORA-06512: at line 1
    ORA-06512: at "PRODNDBA.PROC_RGTR1", line 513
    ORA-06512: at line 1
    external table script is as follows:
    DROP
    TABLE EXT_TABLE_RGTR1 CASCADE CONSTRAINTS;
    CREATE
    TABLE EXT_TABLE_RGTR1
    ID
    VARCHAR2(10 BYTE),
    PC
    VARCHAR2(2 BYTE),
    BU
    VARCHAR2(4 BYTE),
    CONSUMER_NO
    VARCHAR2(12 BYTE),
    CUR_READING1
    NUMBER,
    CUR_READING2
    NUMBER,
    ADJ_CONS1
    NUMBER,
    ADJ_CONS2
    NUMBER,
    TOT_EC
    NUMBER,
    TOT_FCA
    NUMBER,
    TOT_ED
    NUMBER,
    ADDLESS_AMT
    NUMBER,
    NETBILL_AMT
    NUMBER,
    ADJ_UNIT1
    NUMBER,
    ADJ_UNIT2
    NUMBER,
    TARIFF_CODE
    NUMBER,
    DUTY_CODE
    NUMBER,
    DISCONN_TAG
    VARCHAR2(1 BYTE),
    MIN_CHRG_IND
    VARCHAR2(1 BYTE),
    OC_CODE1
    VARCHAR2(1 BYTE),
    OC_CODE2
    VARCHAR2(1 BYTE),
    OC_AMT1
    NUMBER,
    OC_AMT2
    NUMBER,
    PREV_DPC
    NUMBER,
    CREDIT_AVG_BILL
    NUMBER,
    ADJ_TYPES
    NUMBER,
    ADJ_EC_FCA
    NUMBER,
    ADJ_ED
    NUMBER,
    ADJ_AMT1
    NUMBER,
    ADJ_AMT2
    NUMBER,
    ADJ_AMT3
    NUMBER,
    ADJ_AMT4
    NUMBER,
    ADJ_AMT5
    NUMBER,
    ADJ_AMT6
    NUMBER,
    ADJ_AMT7
    NUMBER,
    ADJ_AMT8
    NUMBER,
    MR_CYCLE
    VARCHAR2(2 BYTE),
    NOTICE
    VARCHAR2(2 BYTE),
    INSTAL_IND
    VARCHAR2(1 BYTE),
    LAST_RCPT_DT
    VARCHAR2(6 BYTE),
    MS1
    NUMBER,
    MS2
    NUMBER,
    ARR_PL_CR
    NUMBER,
    PREV_READ1
    NUMBER,
    PREV_READ2
    NUMBER,
    OLD_CONS_NUM
    VARCHAR2(16 BYTE),
    MTR_CODE1
    VARCHAR2(2 BYTE),
    MTR_CODE2
    VARCHAR2(2 BYTE),
    ABR_EC1
    NUMBER,
    ABR_FCA1
    NUMBER,
    REV_CAT
    VARCHAR2(2 BYTE),
    BILL_DT
    DATE,
    SD_PAID
    NUMBER,
    SD_ARRS
    NUMBER,
    SD_ADDL
    NUMBER,
    PR_RDNG_IND1
    VARCHAR2(1 BYTE),
    PR_RDNG_IND2
    VARCHAR2(1 BYTE),
    NAB_IND
    VARCHAR2(1 BYTE),
    CONN_LOAD
    NUMBER,
    OLDEST_OS_DT
    VARCHAR2(4 BYTE),
    ABR_RECAMT1
    NUMBER,
    METER_RENT
    NUMBER,
    EX_DUTY
    NUMBER,
    TDL_CHARGES
    NUMBER,
    ABR_MTH
    VARCHAR2(4 BYTE),
    READING_IND
    VARCHAR2(1 BYTE),
    FB_IND
    VARCHAR2(1 BYTE),
    ADJ_AMT
    NUMBER,
    MTR_NUM1
    NUMBER,
    MTR_NUM2
    NUMBER,
    AVG_UNITS1
    NUMBER,
    AVG_UNITS2
    NUMBER,
    MIN_BILL_AMT
    NUMBER,
    METER_COST_DEMANDED
    NUMBER,
    MF1
    VARCHAR2(2 BYTE),
    MF2
    VARCHAR2(2 BYTE),
    MR
    VARCHAR2(2 BYTE),
    ROUTE
    VARCHAR2(4 BYTE),
    SEQ
    VARCHAR2(4 BYTE),
    DISC_IND
    VARCHAR2(1 BYTE),
    FREEZE_CODE
    VARCHAR2(1 BYTE),
    MTH40
    NUMBER,
    CONCES_EC
    NUMBER,
    METER_COST_ARREARS
    NUMBER,
    METER_COST_PAID
    NUMBER,
    SANCTION_LOAD
    NUMBER,
    PENALTY_ON_CL
    NUMBER,
    CL_SLB
    NUMBER,
    UNTSLB
    NUMBER,
    CAPACIT_PENALTY
    NUMBER,
    ARREARS_OF_INT
    NUMBER,
    INT_ON_ARREARS
    NUMBER,
    FIXED_CHARGES
    NUMBER,
    ASSESSED_DPC
    NUMBER,
    FCA_UNT_OLD
    NUMBER,
    FCA_UNT_NEW
    NUMBER,
    DEFECT_RDN1
    NUMBER,
    DEFECT_RDN2
    NUMBER,
    CAP_CT_RENT
    NUMBER,
    CT_RENT
    NUMBER,
    ADV_BILL_IND
    VARCHAR2(1 BYTE),
    ADV_BILL_RD_IND
    VARCHAR2(1 BYTE),
    INST_IND
    VARCHAR2(1 BYTE),
    CONSCUR_STATUS
    VARCHAR2(1 BYTE),
    MTR_COST1
    NUMBER,
    MTR_COST2
    NUMBER,
    MTR_COST3
    NUMBER,
    LOOM_NOS
    NUMBER,
    CONS_OLD_TARIFF
    NUMBER,
    CONS_NEW_TARIFF
    NUMBER,
    PD_TD_DATE
    VARCHAR2(6 BYTE),
    ED5
    VARCHAR2(10 BYTE),
    ED6
    VARCHAR2(10 BYTE),
    ED8
    VARCHAR2(10 BYTE),
    B66_AMT1
    NUMBER,
    BILL_MTH
    VARCHAR2(6 BYTE),
    STD_MTH
    NUMBER,
    PREV_RD_MTH
    VARCHAR2(4 BYTE),
    ACCT_HD_TRF
    VARCHAR2(2 BYTE),
    ADM_CODE
    NUMBER,
    BILL_DUE_DATE
    DATE,
    EC_DUTY
    NUMBER,
    ABNOR_IND
    VARCHAR2(1 BYTE),
    TRF04_CONN_LOAD
    NUMBER,
    PROCESS_DT
    DATE,
    SUPPLY_DATE
    VARCHAR2(6 BYTE),
    BILL_DT_FROM
    DATE,
    RECEIPT_AMT
    NUMBER,
    LOCKED_CR_UNITS
    NUMBER,
    LOCKED_CHARGES
    NUMBER,
    LOCKED_ED
    NUMBER,
    LOCKED_FCA
    NUMBER,
    LOCKED_FC
    NUMBER,
    LOCKED_RLCHARGES
    NUMBER,
    LOCKED_CL
    NUMBER,
    LOCKED_ECEDFIX
    NUMBER,
    LOCKED_ACC_MONTH
    NUMBER,
    AVG_OLD_CONSMP
    NUMBER(6),
    AVG_SINCE
    VARCHAR2(4 BYTE),
    AVG_OCCURANCES
    NUMBER(2),
    AVG_MA_IND
    VARCHAR2(1 BYTE),
    MTR1_PHASE
    NUMBER(1),
    MTR_PHASE1
    VARCHAR2(1 BYTE),
    MTR2_PHASE
    NUMBER(1),
    IND_CAT
    VARCHAR2(1 BYTE),
    L61_TARIFF
    NUMBER(2),
    MTR_CHG_AMT1
    NUMBER(12),
    NO_OF_MONTHS
    NUMBER,
    MTR_CHG_AMT2
    NUMBER(12),
    B66_AMT
    NUMBER(10),
    ADJ_AMT11
    NUMBER,
    B66_ADJ_TYP
    VARCHAR2(1 BYTE),
    B60_AMT
    NUMBER(10),
    ADJ_AMT13
    NUMBER,
    B60_ADJ_TYP
    VARCHAR2(1 BYTE),
    CPF_NO
    NUMBER(8),
    ADJ1
    NUMBER(9),
    ADJ2
    NUMBER(9),
    ADJ3
    NUMBER(9),
    ADJ4
    NUMBER(9),
    ADJ5
    NUMBER(9),
    ADJ6
    NUMBER(9),
    ADJ7
    NUMBER(9),
    ADJ8
    NUMBER(9),
    ADJ11
    NUMBER(9),
    ADJ13
    NUMBER(9),
    DTC_CODE
    VARCHAR2(7 BYTE),
    TITLE
    VARCHAR2(8 BYTE),
    NAME
    VARCHAR2(36 BYTE),
    ADDRESS1
    VARCHAR2(26 BYTE),
    ADDRESS2
    VARCHAR2(26 BYTE),
    VILLAGE
    VARCHAR2(14 BYTE),
    PIN
    VARCHAR2(6 BYTE),
    LOCK_SINCE
    VARCHAR2(4 BYTE),
    FAULTY_SINCE
    VARCHAR2(4 BYTE),
    MTR_DIGIT1
    VARCHAR2(1 BYTE),
    MTR_DIGIT2
    VARCHAR2(1 BYTE),
    FCA_PAISE
    NUMBER(9),
    GTY_EXP_DT
    VARCHAR2(6 BYTE),
    REJ_READ_MTR1
    NUMBER(6),
    REJ_READ_MTR2
    NUMBER(6),
    REJ_ADJ_UNITS1
    NUMBER(6),
    REJ_CONSMP
    NUMBER(6),
    OWNER_CODE
    NUMBER(1),
    MTR_CAP_AMP
    NUMBER(1),
    MTR_A
    VARCHAR2(1 BYTE),
    MTR_C
    VARCHAR2(1 BYTE),
    MTR_D
    VARCHAR2(1 BYTE),
    MTR_E
    VARCHAR2(1 BYTE),
    CUT_OF_DT
    DATE,
    POLE
    VARCHAR2(6 BYTE),
    EDRATE
    NUMBER(9),
    AREA
    VARCHAR2(1 BYTE),
    MTR_BRAND1
    VARCHAR2(2 BYTE),
    MTR_BRAND2
    VARCHAR2(2 BYTE),
    LC1
    NUMBER(3),
    POWER_CUT_IND
    VARCHAR2(1 BYTE),
    SERVICE_DT
    DATE,
    ADJ_UNIT11
    NUMBER,
    ADJ_UNIT22
    NUMBER,
    RECEIPT_AMT1
    NUMBER,
    MTR1
    NUMBER,
    STRK_BLL_AMT
    NUMBER,
    DUTY_UNTS1
    NUMBER,
    DUTY_AMT1
    NUMBER,
    DUTY_UNTS2
    NUMBER,
    DUTY_AMT2
    NUMBER,
    DUTY_UNTS3
    NUMBER,
    DUTY_AMT3
    NUMBER,
    ADJ_UNIT_45
    NUMBER,
    ADV_BIL_EC
    NUMBER,
    NEW_DUTY_RATE
    NUMBER,
    NEW_DUTY_UNTS
    NUMBER,
    NEW_DUTY_AMT
    NUMBER,
    DPC_PAB
    NUMBER,
    MS9_SINCE
    VARCHAR2(4 BYTE),
    DISTRICT_CODE
    NUMBER(2),
    TAX_ON_SALE
    NUMBER,
    LOCKED_CHARGES_TSE
    NUMBER
    ORGANIZATION
    EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY EXT_DIR
    ACCESS PARAMETERS
    ( records delimited by newline
    badfile
    'ext.bad'
    logfile 'ext.log'
    fields
    ID POSITION
    (1-4),
    PC POSITION
    (7-7),
    BU POSITION
    (8-11),
    CONSUMER_NO POSITION
    (18-29 ),
    CUR_READING1 POSITION
    (33-41 ),
    CUR_READING2 POSITION
    (42-50 ),
    ADJ_CONS1 POSITION
    (51-59 ),
    ADJ_CONS2 POSITION
    (60-68 ),
    TOT_EC POSITION
    (69-86),
    TOT_FCA POSITION
    (87-104 ),
    TOT_ED POSITION
    (105-122 ),
    ADDLESS_AMT POSITION
    (123-140 ),
    NETBILL_AMT POSITION
    (141-158 ),
    ADJ_UNIT1 POSITION
    (159-167 ),
    ADJ_UNIT2 POSITION
    (168-176 ),
    TARIFF_CODE POSITION
    (177-178 ),
    DUTY_CODE POSITION
    (179-180 ),
    DISCONN_TAG POSITION
    (181-181 ),
    MIN_CHRG_IND POSITION
    (182-182 ),
    OC_CODE1 POSITION
    (183-183 ),
    OC_CODE2 POSITION
    (184-184 ),
    OC_AMT1 POSITION
    (185-202 ),
    OC_AMT2 POSITION
    (203-220 ),
    PREV_DPC POSITION
    (221-238 ),
    CREDIT_AVG_BILL POSITION
    (239-256 ),
    ADJ_TYPES POSITION
    (257-264 ),
    ADJ_EC_FCA POSITION
    (265-282 ),
    ADJ_ED POSITION
    (283-300 ),
    ADJ_AMT1 POSITION
    (301-318 ),
    ADJ_AMT2 POSITION
    (319-336 ),
    ADJ_AMT3 POSITION
    (337-354 ),
    ADJ_AMT4 POSITION
    (355-372 ),
    ADJ_AMT5 POSITION
    (373-390 ),
    ADJ_AMT6 POSITION
    (391-408 ),
    ADJ_AMT7 POSITION
    (409-426 ),
    ADJ_AMT8 POSITION
    (427-444 ),
    MR_CYCLE POSITION
    (445-446 ),
    NOTICE POSITION
    (447-448 ),
    INSTAL_IND POSITION
    (449-449 ),
    LAST_RCPT_DT POSITION
    (453-458 ),
    MS1 POSITION
    (459-459),
    MS2 POSITION
    (460-460),
    ARR_PL_CR POSITION
    (461-478 ),
    PREV_READ1 POSITION
    (479-487 ),
    PREV_READ2 POSITION
    (488-496 ),
    OLD_CONS_NUM POSITION
    (497-512 ),
    MTR_CODE1 POSITION
    (513-514 ),
    MTR_CODE2 POSITION
    (515-516 ),
    ABR_EC1 POSITION
    (517-534 ),
    ABR_FCA1 POSITION
    (535-552 ),
    REV_CAT POSITION
    (553-554 ),
    BILL_DT POSITION
    (555-560 ) DATE "DDMMYY",
    SD_PAID POSITION
    (561-569 ),
    SD_ARRS POSITION
    (570-578 ),
    SD_ADDL POSITION
    (579-587 ),
    PR_RDNG_IND1 POSITION
    (588-588 ),
    PR_RDNG_IND2 POSITION
    (589-589 ),
    NAB_IND POSITION
    (590-590 ),
    CONN_LOAD POSITION
    (592-600 ),
    OLDEST_OS_DT POSITION
    (601-604 ),
    ABR_RECAMT1 POSITION
    (605-622 ),
    METER_RENT POSITION
    (623-631 ),
    EX_DUTY POSITION
    (632-649 ),
    TDL_CHARGES POSITION
    (632-649 ),
    ABR_MTH POSITION
    (650-651 ),
    READING_IND POSITION
    (652-652 ),
    FB_IND POSITION
    (653-653 ),
    ADJ_AMT POSITION
    (654-671 ),
    MTR_NUM1 POSITION
    (672-681 ),
    MTR_NUM2 POSITION
    (682-691 ),
    AVG_UNITS1 POSITION
    (692-700 ),
    AVG_UNITS2 POSITION
    (701-709 ),
    MIN_BILL_AMT POSITION
    (710-727 ),
    METER_COST_DEMANDED POSITION
    (710-727 ),
    MF1 POSITION
    (728-729),
    MF2 POSITION
    (730-731),
    MR POSITION
    (732-733),
    ROUTE POSITION
    (734-737),
    SEQ POSITION
    (738-741),
    DISC_IND POSITION
    (742-742 ),
    FREEZE_CODE POSITION
    (743-743 ),
    MTH40 POSITION
    (744-752),
    CONCES_EC POSITION
    (753-770 ),
    METER_COST_ARREARS POSITION
    (753-770 ),
    METER_COST_PAID POSITION
    (771-788 ),
    SANCTION_LOAD POSITION
    (789-797 ),
    PENALTY_ON_CL POSITION
    (798-815 ),
    CL_SLB POSITION
    (816-817 ),
    UNTSLB POSITION
    (818-819 ),
    CAPACIT_PENALTY POSITION
    (820-837 ),
    ARREARS_OF_INT POSITION
    (838-855 ),
    INT_ON_ARREARS POSITION
    (856-873 ),
    FIXED_CHARGES POSITION
    (874-891 ),
    ASSESSED_DPC POSITION
    (892-909 ),
    FCA_UNT_OLD POSITION
    (910-927 ),
    FCA_UNT_NEW POSITION
    (928-945 ),
    DEFECT_RDN1 POSITION
    (982-990 ),
    DEFECT_RDN2 POSITION
    (991-999 ),
    CAP_CT_RENT POSITION
    (1000-1008 ),
    CT_RENT POSITION
    (1009-1017 ),
    ADV_BILL_IND POSITION
    (1018-1018 )
    LOCATION
    (EXT_DIR:'rgtr1.txt')
    REJECT
    LIMIT UNLIMITED
    LOGGING
    NOCACHE
    NOPARALLEL;

    KUP-04020: found record longer than buffer size supported, number, in string
    Cause: a record in the data source was longer than the maximum data size supported. The number reported is the maximum supported size of a record.
    Action: none
    Examine your bad file and log files for details of the rows which failed from insertion.

  • External tables-Fixed length file

    Hi All,
    I have a fixed length file that i load daily using an External table. Recently, one of the field, IP length was changed and customer wants to send both old records with 8 byte length and new records with 11 byte length in the same data file, until complete migration takes place.
    Will it be possible for External tables to handle this requirement?. Or Is there any other possibility to treat it.
    The old file contains 104 fields with IP field position form 490 to 498. Total
    The new file contains 104 fields with the IP position from 490 to 501.
    Thanks,
    Sri.

    If the two record types are mixed in the same file, then you will have problems loading them. I can see two possible solutions, in no particular order of preference (using your example data):
    1. Redefine the external table something like:
    Position (record_type (1:1)
              version     (2:5)
              data        (6:41))then parse the remaining fields based on the version number when you select from the external table.
    2. Create two external tables over the same file, one for version 1.00 and one for version 1.01 using the LOAD WHEN clause to determine which set of data to load when you select. Something like:
    CREATE TABLE version1 ...
    ORGANIZATION EXTERNAL ...
    ACCESS PARAMETERS
    (RECORDS DELIMITED BY newline
      LOAD WHEN (version = 1.00)
    < definition for the old format >
    and
    CREATE TABLE version101 ...
    ORGANIZATION EXTERNAL ...
    ACCESS PARAMETERS
    (RECORDS DELIMITED BY newline
      LOAD WHEN (version = 1.01)
    < definition for the new format >Then yor processing would use something like:
    SELECT ip, last_name
    FROM version1
    UNION ALL
    SELECT ip, last_name
    FROM version101HTH
    John

  • External Table Application

    Trying to install the External_Table_Simple_0.9 application but I am receiving errors.
    I installed the application but it could not see the flat file, so I de-installed and on re-install I got these errors.
    report error:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04063: unable to open log file EXT_EMPLOYEES_EXTERNAL_5476_2344.log
    OS error The data is invalid.
    Has anybody experienced this.
    Gus

    Gus,
    Copy and paste will not do the work every time.
    I copied and pasted the package definition you posted and it won't compile. One
    of the declarations is not properly quoted:
    x :=
             q'! comment on table ext_employees is 'Data loaded: !'
          || TO_CHAR (SYSDATE, 'FMDay, Mon ddth, hh:mi am');
       x := x || q'! by !' || NVL (v ('APP_USER'), USER) || q'!' !';
       EXECUTE IMMEDIATE x;
    ...Other than that, you also had an inproper positioning specification here:
    FIRST_NAME position(8:22),
    last_name position(23:34),
    where you didn't consider whitspace between the two columns.
    I assume the file you use is of fixed column length. I used the information
    you pasted here and modified it accordingly to get a fixed lenght of the columns:
    EMP_ID FIRST_NAME LAST_NAME EMAIL    PHONE_NUMBER HIRE_DATE  JOB_ID  SALARY COMM_PCT MGR_ID DEPT_ID
    100    Steven     King      SKING    515.123.4567 06/17/1987 AD_PRES 24000           90
    101    Neena      Kochhar   NKOCHHAR 515.123.4568 09/21/1989 AD_VP   17000           100    90
    102    Lex        De Haan   LDEHAAN  515.123.4569 01/13/1993 AD_VP   17000           100    90
    103    Al         Hunold    AHUNOLD  590.423.4567 01/03/1990 IT_PROG 9000            102    60Saved it as employees.txt into the directory DATA_LOAD.
    Running the following script will create an external table:
    CREATE TABLE ext_employees_external
      employee_id     VARCHAR(20),
      first_name      VARCHAR(20),
      last_name       VARCHAR(20),
      email           VARCHAR(20),
      phone_number    VARCHAR(20),
      hire_date       VARCHAR(20),
      job_id          VARCHAR(20),
      salary          VARCHAR(20),
      commission_pct  VARCHAR(20),
      manager_id      VARCHAR(20),
      department_id   VARCHAR(20)
    ORGANIZATION EXTERNAL
      (  TYPE oracle_loader
         DEFAULT DIRECTORY data_load
         ACCESS PARAMETERS
           ( RECORDS DELIMITED BY NEWLINE
    SKIP 2
    FIELDS MISSING FIELD VALUES ARE NULL(
    employee_id POSITION(001:006),
    first_name POSITION(008:0017),
    last_name POSITION(019:027),
    email POSITION(029:036),
    phone_number POSITION(038:049),
    hire_date POSITION(051:060) ,
    job_id POSITION(062:068),
    salary POSITION(070:075),
    commission_pct POSITION(077:083),
    manager_id POSITION(086:092),
    department_id POSITION(093:100)
         LOCATION (data_load:'employees.txt')
    REJECT LIMIT 10
    NOPARALLEL
    NOMONITORING;This table is reading the data properly. You may now include this in your procedure.
    You certanly need to have a look at your .txt file and exactly determie the column
    widths. I was using varchar2 in the column definiton of the extenal table. Since you are
    loading the external table into your "real" table, you may want to perform data
    conversion at that point.
    The directory I specified in this script is DATA_LOAD. Your directory may be different.
    Denes Kubicek

  • External table

    Hi,
    I have an external table called ext_tab, i want to drop and create with some additional column. When i try to recreate it, I'm getting an error
    ORA-30657: OPERATION NOT SUPPORTED .
    Can anyone tell me how to recreate the external table?
    Thanks,
    GK

    I'm trying to run the following SQL:
    CREATE TABLE EXT_test
    ROW_ID NUMBER(10),
    ACTION VARCHAR2(1),
    MP NUMBER(7)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY STARLINKDIR
    ACCESS PARAMETERS
    ( records delimited by newline
    badfile 'STARLINKDIR':'test.bad'
    logfile 'test.log'
    fields
    (row_id position(1:10),
    ACTION position(11:11),
    MP position(12:18)
    LOCATION (STARLINKDIR:'test.dat')
    REJECT LIMIT UNLIMITED
    NOLOGGING
    NOCACHE
    NOPARALLEL;

  • External Table - Issues With Special Character.

    I have an external table that reads from a fixed length file. The file is expected to contain special characters. In my case the word containing special character is "Göteborg". Because "ö" is a special character, looks like Oracle is considering it as 2 bytes. That causes the trouble. The subsequent fields in the files get shifted by 1 byte thereby messing up the data. Has anyone faced the issue before. So far we have tried the following solution:
    Changed the value of NLS_LANG to AMERICAN_AMERICA.WE8ISO8859P1
    Tried Setting the Database Character set to UTF-8
    Tried changing the NLS_LENGTH_SYMMANTIC to CHAR instead of BYTE using ALTER SYSTEM
    Tried changing the External table characterset to: AL32UTF8
    Tried changing the External table characterset to: UTF-8
    Nothing works. Other details include:
    • File is UTF-8 encoded
    • Operating System : RHEL
    • Database: Oracle 11gR2
    Any thing else that I might be missing? Any help will be appreciated. Thanks in advance!
    Ganesh

    CREATE TABLE "APP_XXX_XX_XXXX"(
    "KEY_NO" NUMBER,
    "XXX_XXX_XXXXX" VARCHAR2(1 CHAR),
    "XXX_XXX_XXXXX" NUMBER(9,0),
    "XXX_XXX_XXXXX" NUMBER(4,0),
    "XXX_XXX_XXXXX" NUMBER(2,0),
    "XXX_XXX_XXXXX" NUMBER(3,0))
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY "DIR"
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY NEWLINE
    CHARACTERSET 'UTF8'
    LOGFILE APP_XXX_XX_XXXX_%A_%P.LOG'
    BADFILE 'APP_XXX_XX_XXXX_%A_%P.BAD'
    DISCARDFILE 'APP_XXX_XX_XXXX_%A_%P.DSC'
    FIELDS(
    KEY_NO POSITION(1:9) INTEGER EXTERNAL,
    XXX_XXX_XXXXX POSITION(10:10) CHAR,
    XXX_XXX_XXXXX POSITION(11:19) INTEGER EXTERNAL,
    XXX_XXX_XXXXX POSITION(11:14) INTEGER EXTERNAL,
    XXX_XXX_XXXXX POSITION(15:16) INTEGER EXTERNAL,
    XXX_XXX_XXXXX POSITION(17:19) INTEGER EXTERNAL)
    LOCATION
    ( 'FILE1.TXT')
    REJECT LIMIT UNLIMITED
    PARALLEL 4;
    The data forms part of a major driver table, which I may not be able to provide as per the NDA with my company.
    The Script I have shared is standard template for creating external table as part of our applications.
    We majorly cater for EU regions with this project.(European Characterset needed to be supported)
    Thanks
    Ganesh
    Edited by: RGRAM on Feb 11, 2011 12:44 PM

  • External Table 4-   Default Values

    Hi
    My External Table is working fine , but I want put Default Values when Null, Example when COD_REJ is NULL I want Put 3 spaces
    CREATE TABLE SPAYDES.TB_EXT_BONUS
      SEQ       CHAR(11 BYTE),
      CNPJ      CHAR(14 BYTE),
      CARTAO    CHAR(16 BYTE),
      NOME      CHAR(30 BYTE),
      MATR_ATU  CHAR(10 BYTE),
      MATR_NEW  CHAR(10 BYTE),
      SIT_REG   CHAR(1 BYTE),
      COD_REJ   CHAR(3 BYTE)
    ORGANIZATION EXTERNAL
      (  TYPE ORACLE_LOADER
         DEFAULT DIRECTORY EXT_DIR_BONUS
         ACCESS PARAMETERS
           ( records delimited by newline
         fields (
           SEQ       position(1: 11) CHAR(11),
           CNPJ      position(12:25) CHAR(14),
           CARTAO    position(26:41) CHAR(16),
           NOME      position(42:71) CHAR(30),
           MATR_ATU  position(72:81) CHAR(10),
           MATR_NEW  position(82:91) CHAR(10),
           SIT_REG   position(92:92) CHAR(1),
           COD_REJ   position(93:95) CHAR(3))
         LOCATION (EXT_DIR_BONUS:'BONUS.TXT')
    REJECT LIMIT UNLIMITEDThank You

    never tried by may be you can do this? Not sure on
    this one.
    COD_REJ position(93:95) CHAR(3) default '   '
    I tried , but
    SQL> SELECT * FROM SPAYDES.TB_EXT_BONUS;
    SELECT * FROM SPAYDES.TB_EXT_BONUS
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "identifier": expecting one of: "comma, date_format, defaultif, enclosed, ltrim, lrtrim, ldrtrim, notrim, nullif, optionally, ), rtrim, terminated"
    KUP-01008: the bad identifier was: DEFAULT
    KUP-01007: at line 9 column 42
    ORA-06512: at "SYS.ORACLE_LOADER", line 14
    ORA-06512: at line 1
    SQL>

  • External table headache

    Hi there!
    Got this problem that are driving me quite mad.
    I'm working on a Oracle 9.2.0.7, Unix is a hp-ux.
    The problem is:
    using an external table, record in variable format, with '^' as separetor, if file size is an exact power of 1024 (i.e. 1K, 2k, 1M etc) I get the error:
    reject limit reached
    The strange thing is that the file is correct, anc other files are loaded with no problem at all.
    For now the "work around" is to edit the file (vi on file so we check that there aren't strange chars) and then add a space at the end of it.
    After this the file is loaded!
    Anyone have an idea?
    Thank you,
    Antonio

    Sorry guys, I was a bit busy.
    I've talked with a coworker, we got an example of a table and a more precise idea: it's not "power of 1K" but "power of 1M"
    This is the example table:
    CREATE TABLE ext_table
    c_field_1 CHAR(1),
    v_field_2 VARCHAR2(15),
    v_field_3 VARCHAR2(24),
    v_field_4 VARCHAR2(24),
    v_field_5 VARCHAR2(14),
    v_field_6 VARCHAR2(14),
    n_field_7 NUMBER(6,0),
    n_field_8 NUMBER(6,0),
    n_field_9 NUMBER(10,0),
    v_field_10 VARCHAR2(79),
    v_field_11 VARCHAR2(12),
    c_field_12 CHAR(1),
    v_field_13 VARCHAR2(2),
    v_field_14 VARCHAR2(7),
    v_field_15 VARCHAR2(30),
    v_field_16 VARCHAR2(14),
    d_field_17 DATE,
    n_field_18 NUMBER(8,0),
    d_field_19 DATE,
    n_field_20 NUMBER(8,0),
    v_field_21 VARCHAR2(191),
    d_field_22 DATE,
    n_field_23 NUMBER(8,0),
    v_field_24 VARCHAR2(2),
    n_field_25 NUMBER(6,0),
    n_field_26 NUMBER(10,0))
    ORGANIZATION EXTERNAL (
    DEFAULT DIRECTORY DR_LOAD
    ACCESS PARAMETERS(records delimited by newline
    badfile 'DR_ERROR':'EXT_TABLE_LOAD.error'
    logfile 'DR_LOG':'EXT_TABLE_LOAD.log'
    fields (
         c_field_1 POSITION(2:2)     CHAR(1)
         ,v_field_2 POSITION(3:17)     CHAR(15)
         ,v_field_3 POSITION(18:41)     CHAR(24)
         ,v_field_4 POSITION(42:65)     CHAR(24)
         ,v_field_5 POSITION(66:79)     CHAR(14)
         ,v_field_6 POSITION(80:93)     CHAR(14)
         ,n_field_7 POSITION(94:99)     INTEGER EXTERNAL(6)
         ,n_field_8 POSITION(100:105)     INTEGER EXTERNAL(6)
         ,n_field_9 POSITION(106:115)     INTEGER EXTERNAL(10)
         ,v_field_10 POSITION(116:194)     CHAR(79)
         ,v_field_11 POSITION(195:206)     CHAR(12)
         ,c_field_12 POSITION(207:207)     CHAR(1)
         ,v_field_13 POSITION(208:209)     CHAR(2)
         ,v_field_14 POSITION(210:216)     CHAR(7)
         ,v_field_15 POSITION(217:246)     CHAR(30)
         ,v_field_16 POSITION(247:260)     CHAR(14)
         ,d_field_17 POSITION(261:274)     DATE YYYYMMDDHH24MISS
         ,n_field_18 POSITION(261:268)     INTEGER EXTERNAL(8)
         ,d_field_19 POSITION(275:288)     DATE YYYYMMDDHH24MISS
         ,n_field_20 POSITION(275:282)     INTEGER EXTERNAL(8)
         ,v_field_21 POSITION(289:479)     CHAR(191)
         ,d_field_22 POSITION(480:493)     DATE YYYYMMDDHH24MISS
         ,n_field_23 POSITION(480:487)     INTEGER EXTERNAL(8)
         ,v_field_24 POSITION(494:495)     CHAR(2)
         ,n_field_25 POSITION(496:501)     INTEGER EXTERNAL(6)
         ,n_field_26 POSITION(502:511)     INTEGER EXTERNAL(10)
    LOCATION (
    DR_LOAD:'EXT_TABLE_LOAD'
    and a row
    2T0123456789 11111111 2008091008264220080910092642020202020304000000000200613359956 0006133599560L2*************************************999912310000002008091008264220080910092642L2061335995620202203042008091008264220080910092642 20090319112538000808291000021162
    If you replicate the row, that is 512 byte, 2048 times so you will have a file that is exactly 1MB, then any select on the external table will fail.
    The error log EXT_TABLE_LOAD.log says:
    KUP-04021: field formatting error for field C_FIELD_1
    KUP-04023: field start is after end of record
    KUP-04101: record 2049 rejected in file <file>
    (NOTE: it's not true, the file is correct! if you try to load the single row it will load nicely)
    and you'll have an empty EXT_TABLE_LOAD.error
    Hope this will help.
    Bye,
    Antonio

  • Calling functions in External tables

    I'm trying to create an External table and assigning a function return value to a column. But I'm getting error when trying to retrieve data from the table. Below are the scripts and error message. Can someone point me the correction.
    create or replace
    function v_sum ( v_num1 number, v_num2 number) return number as
    v_res number;
    begin
    v_res := v_num1 + v_num2;
    return v_res;
    end;
      create table tab_xyz
        col1 varchar2(10),
        col2 varchar2(10),
        col3 number
      ORGANIZATION EXTERNAL
        TYPE ORACLE_LOADER DEFAULT DIRECTORY "MF_DIR" ACCESS PARAMETERS (
        records delimited BY newline
        load when (col1 != blanks)
        badfile mf_dir:'xyz.csv.bad'
        logfile mf_dir:'xzy.csv.log'
        discardfile mf_dir:'xyz.csv.dsc'
        fields terminated BY ',' optionally enclosed BY '"' MISSING FIELD VALUES ARE NULL 
        (col1,
         col2,
         col3 v_sum(3,4))
        LOCATION ('xyz.csv' )) 
      REJECT LIMIT 100; 
    Error starting at line 4 in command:
    select * from tab_xyz
    Error report:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "identifier": expecting one of: "binary_double, binary_float, comma, char, date, defaultif, decimal, double, float, integer, (, nullif, oracle_date, oracle_number, position, raw, recnum, ), unsigned, varrawc, varchar, varraw, varcharc, zoned"
    KUP-01008: the bad identifier was: v_sum
    KUP-01007: at line 9 column 11
    29913. 00000 -  "error in executing %s callout"
    *Cause:    The execution of the specified callout caused an error.
    *Action:   Examine the error messages take appropriate action.Thanks

       fields terminated BY ',' optionally enclosed BY '"' MISSING FIELD VALUES ARE NULL 
        (col1,
         col2,
         col3 EXPRESSION "v_sum(3,4)")
        LOCATION ('xyz.csv' )) 
      REJECT LIMIT 100; 
    KUP-01005: syntax error: found "identifier": expecting one of: "binary_double, binary_float, comma, char, date, defaultif, decimal, double, float, integer, (, nullif, oracle_date, oracle_number, position, raw, recnum, ), unsigned, varrawc, varchar, varraw, varcharc, zoned"
    KUP-01008: the bad identifier was: EXPRESSION

Maybe you are looking for

  • Is it good to have more key fields in DSO

    Hey Guys , is it good to have more key filds in dso , and how will it impact the performance of  Loading/Access. Anurag

  • Item Category 'L' (Subcontracting)

    Hello, I would just like to ask if a UB-type PO (Stock Transfer Order) could have an item category 'L' which is Subcontracting. Currently, only item category 'U' (Stock Transfer) is available in the item category field when creating a UB-type PO thro

  • Retreiving and setting fields from pdf

    Hi Everyone, I hope that you may be able to help. I'm working on putting together an extention to my program to allow users to load a pdf file from a database, and also save what the user has entered into the pdf, into a database. I started out using

  • CRM 5.2,  how to define an assignment set in the runtime depository?

    We are using CRM 5.2. I have created a new component and view and the view is exposed as an interface view. Now i have to include this in the overview page of BP_HEAD component. I have enhanced BP_HEAD component and enhanced the view required as well

  • Photo storage space

    so guys, today i was looking in my itunes and it says i got like 6GB of photos, i erased all the ones that sync with the computer, but still got 2.9GB of pictures.... i have about 200 photos in my camera roll.... how is this possible?? i just want to