External Table : ROW Delimiter

Hi,
I am working on an interesting solution that invloves modifying the definitions of External Tables dynamically. I have created a Procedure that alters the delimiters ( ROW and COLUMN ) using Dynamic SQL.
CREATE OR REPLACE PROCEDURE SP_CHANGE_DELIMITER
     P_RECORD_DELIM     VARCHAR2,
     P_FIELD_DELIM     VARCHAR2,
     P_DEBUG          NUMBER   DEFAULT 0     
AS
          P_RECORD_DELIM_ VARCHAR2(100):= P_RECORD_DELIM;
          P_FIELD_DELIM_  VARCHAR2(100):= P_FIELD_DELIM;
          sql_          VARCHAR2(4000);
     BEGIN
          IF P_RECORD_DELIM_ IS NOT NULL
          THEN
               P_RECORD_DELIM_ := ''''||P_RECORD_DELIM_||'''';
          ELSE
               P_RECORD_DELIM_ := 'NEWLINE';
          END IF;
          IF P_FIELD_DELIM_ IS NOT NULL
          THEN
               P_FIELD_DELIM_ := ''''||P_FIELD_DELIM_||'''';
          END IF;
          sql_:=
                    ALTER TABLE EXTERN_EMPL_RPT
                    ACCESS PARAMETERS
                         RECORDS DELIMITED BY '||P_RECORD_DELIM_||'
                         FIELDS TERMINATED BY '||P_FIELD_DELIM_ ||'
          IF NVL(P_DEBUG,0) = 1 THEN
               DBMS_OUTPUT.PUT_LINE(sql_);
          END IF;
          EXECUTE IMMEDIATE sql_;
     END;I am able to dynamically change the Definition of the CLOUM Delimiter using my Procedure :-
EXEC SP_CHANGE_DELIMITER(P_RECORD_DELIM=> '', P_FIELD_DELIM => '*',P_DEBUG=>1);However, when I try to change the ROW Delimiter, I am getting this error :-
EXEC SP_CHANGE_DELIMITER(P_RECORD_DELIM=> '|', P_FIELD_DELIM => '#',P_DEBUG=>1);
SQL> SELECT * FROM EXTERN_EMPL_RPT;
SELECT * FROM EXTERN_EMPL_RPT
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEFETCH callout
ORA-30653: reject limit reached
ORA-06512: at "SYS.ORACLE_LOADER", line 52
ORA-06512: at line 1I am working with data that looks like this:-
001 | Sandeep | Seshan
002 | Seshan   | SandeepIf I try to change this to :-
001 # Sandeep #  Seshan  |
002 # Seshan   # Sandeep |I get the ORA-29913 error.
Can you please help me with this sticky bit ?
Please do let me know if I need to include more information.
Thanks,
Sandeep

Try increasing reject limit to unlimited!
ALTER TABLE EXTERN_EMPL_RPT REJECT LIMITED UNLIMITED;

Similar Messages

  • How to reject external table rows with some blank columns

    How to reject external table rows with some blank columns
    I have an external table and I would like to reject rows when a number of fields are empty. Here are the details.
    CREATE TABLE EXTTAB (
    ID NUMBER(10),
    TSTAMP DATE,
    C1 NUMBER(5,0),
    C2 DATE,
    C3 FLOAT(126)
    ORGANIZATION EXTERNAL (
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY EXT_DAT_DIR
    ACCESS PARAMETERS (
    RECORDS DELIMITED BY NEWLINE
    LOAD WHEN (NOT (c1 = BLANKS AND c2 = BLANKS AND c3 = BLANKS))
    LOGFILE EXT_LOG_DIR:'exttab.log'
    BADFILE EXT_BAD_DIR:'exttab.bad'
    DISCARDFILE EXT_BAD_DIR:'exttab.dsc'
    FIELDS TERMINATED BY "|"
    LRTRIM
    MISSING FIELD VALUES ARE NULL
    REJECT ROWS WITH ALL NULL
    FIELDS (
    ID,
    TSTAMP DATE 'YYYYMMDDHH24MISS',
    C1,
    C2 DATE 'YYYYMMDDHH24MISS',
    C3
    ) LOCATION ('dummy.dat')
    REJECT LIMIT UNLIMITED
    So, as you can see from the LOAD WHEN clause, I'd like to reject rows when C1, C2 and C3 are empty.
    The above statement works fine and creates the table. However when I am trying to load data using it, the following error is produced:
    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 "not": expecting one of: "double-quoted-string, identifier, (, number, single-quoted-string"
    KUP-01007: at line 1 column 41
    ORA-06512: at "SYS.ORACLE_LOADER", line 14
    ORA-06512: at line 1
    It seems that external tables driver does not understand the "NOT (...)" condition. Could anyone suggest how I can achieve what I want in a different way?
    Thank you.
    Denis

    Another method would be to simply remove the "LOAD WHEN condition" and create a view on the external table which filters the data.
    CREATE EXTTAB_VIEW AS
    SELECT * FROM EXTTAB
    WHERE not (c1 is null and c2 is null and c3 is null);

  • External Table, Handling Delimited and Special Character in file

    Hi ,
    I have created one external table with these option
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY ***************************************
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY NEWLINE
    SKIP 0
    FIELDS TERMINATED BY '|'
    OPTIONALLY ENCLOSED BY '"'
    MISSING FIELD VALUES ARE NULL                                          
    LOCATION
    ( 'test_feed.csv'
    Now problem is these are coming as valid.
    anupam|anupam2
    anupam"test|anupam"test2
    "anupam|test3"|test3
    anupam""""test5|test5
    anupam"|test7
    but these are not coming as valid
    "anupam"test4"|test4    --> Case when we have quotes in the filed but still have quotes in it. I guess in this case we can send the filed expect closing double quotes.
    "anupam|test6   --> In case field is starting with double quotes then it's failing
    "anupam"test8|test8"|test8 --> In case one filed contains both pipe ( |) and double quotes then we are sending it enclosed in double quotes. But thats failing the job.
    Can you suggest what is the best way to handle such scenario? ( One restriction though. The file is used by other system - Netezza as well, which can't take more than one character long delimited :'( )

    One approach is to define the external table a ONE column table (with single field on the file). This way each line will come in as a row in the external table. Of course you have to build "parsing logic" on top of that.
    DROP TABLE xtern_table;
    CREATE TABLE xtern_table
        c1 VARCHAR2(4000)
      organization external
        type ORACLE_LOADER DEFAULT directory xtern_data_dir
        ACCESS PARAMETERS (
            RECORDS DELIMITED BY NEWLINE
            FIELDS TERMINATED BY '~'   ---- <<<<<<<< Use a field terminator as a character that is not found in the file
            MISSING FIELD VALUES ARE NULL
            ( c1 CHAR(4000)
         ) location ('mycsv.csv')
    > desc xtern_table
    desc xtern_table
    Name Null Type          
    C1        VARCHAR2(4000)
    > column c1 format A40
    > select * from xtern_table
    C1                                    
    anupam|anupam2                          
    anupam"test|anupam"test2                
    "anupam|test3"|test3                    
    anupam""""test5|test5                   
    anupam"|test7                           
    "anupam"test4"|test4                    
    "anupam|test6                           
    "anupam"test8|test8"|test8              
    8 rows selected
    Ideally, it will be good t have an incoming source file with predictable format.
    Hope this helps.

  • External Table - Record delimiter

    Hi,
    Is it possible to have combination of character and NEWLINE as a record delimiter in external table. i.e something like RECORDS DELIMITED BY '#^'||chr(10)
    Thanks
    S. Sathish Kumar

    you can always read the manuals
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch12.htm#1007431
    assuming that you mean you have the #^ at the end of the line, then it's just
    RECORDS DELIMITED BY '#^'
    if you mean that you sometimes have #^ in the middle, and only break when it's at the end of the line, then you need to use (on windows)
    RECORDS DELIMITED BY '#^\r\n'

  • External Table Skip Row

    I've created external table, but how do I get the external table to skip the header and footer?
    CREATE TABLE "KAS_EXT"
    CUSTOMERID VARCHAR2(9),
    CANVASSID VARCHAR2(9),
    REPID VARCHAR2(9)
    ORGANIZATION external
    TYPE oracle_loader
    DEFAULT DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000
    ACCESS PARAMETERS
    RECORDS DELIMITED BY NEWLINE CHARACTERSET WE8MSWIN1252
    BADFILE 'kaslist_ext_devt_water.bad'
    LOGFILE 'kaslist_ext_devt_water.log_xt'
    READSIZE 1048576
    FIELDS TERMINATED BY "," LDRTRIM
    MISSING FIELD VALUES ARE NULL
    SKIP 1 <<<<<<<<<<<<<<< here???
    REJECT ROWS WITH ALL NULL FIELDS
    CUSTOMERID CHAR(255)
    TERMINATED BY ",",
    CANVASSID CHAR(255)
    TERMINATED BY ",",
    REPID CHAR(255)
    TERMINATED BY ","
    location
    'kas.csv'
    )REJECT LIMIT UNLIMITED

    I don't know of any way to make it automatically skip footers. Hopefully, the footer doesn't match your data structure, so that it couldn't get loaded as a record, then it would just go to your bad file.

  • How to find rejected rows using External Table

    Hi all,
    I had written a stored procedure to read comma(,) separated flat file using External Tables in oracle 9i with Reject Limit "Unlimited" Option. Sometimes all rows are successfully loaded into external table and sometimes some rows are failed, I can find out those rows from logfile created by oracle. I want to inserted those rows key values into some other table. Can any body suggest/links how to write this.
    Thanking you in advance

    "Is there a way to have the system truncate the log files besides some O/S utility that will scour the directory every night, week, etc.?"
    You can use UTL_FILE.FREMOVE to delete the file, if you have sufficient privileges. You can schedule it using DBMS_JOB if you like or run it before you recreate the file, as demonstrated below. The pl/sql block to check whether the file exists is used for demonstration purposes only and is not necessary. This is just one method. There are various ways to delete or truncate a file. This just seems like the simplest.
    scott@ORA92> CREATE OR REPLACE DIRECTORY mydir AS 'c:\oracle'
      2  /
    Directory created.
    scott@ORA92> DECLARE
      2    v_bfile BFILE := BFILENAME ('MY_DIR', 'test_tab.log');
      3  BEGIN
      4    IF DBMS_LOB.FILEEXISTS (v_bfile) = 1
      5    THEN DBMS_OUTPUT.PUT_LINE ('test_tab.log exists');
      6    ELSE DBMS_OUTPUT.PUT_line ('test_tab.log does not exist');
      7    END IF;
      8  END;
      9  /
    test_tab.log exists
    PL/SQL procedure successfully completed.
    scott@ORA92> EXECUTE UTL_FILE.FREMOVE ('MY_DIR', 'test_tab.log')
    PL/SQL procedure successfully completed.
    scott@ORA92> DECLARE
      2    v_bfile BFILE := BFILENAME ('MY_DIR', 'test_tab.log');
      3  BEGIN
      4    IF DBMS_LOB.FILEEXISTS (v_bfile) = 1
      5    THEN DBMS_OUTPUT.PUT_LINE ('test_tab.log exists');
      6    ELSE DBMS_OUTPUT.PUT_line ('test_tab.log does not exist');
      7    END IF;
      8  END;
      9  /
    test_tab.log does not exist
    PL/SQL procedure successfully completed.
    scott@ORA92> CREATE TABLE test_tab
      2    (col1 NUMBER,
      3       col2 VARCHAR2(4))
      4  ORGANIZATION external
      5    (TYPE ORACLE_LOADER
      6       DEFAULT DIRECTORY mydir
      7       ACCESS PARAMETERS
      8         (RECORDS DELIMITED BY NEWLINE
      9          BADFILE 'MYDIR':'test_bad.bad'
    10          LOGFILE 'MYDIR':'test_tab.log'
    11          FIELDS TERMINATED BY ","
    12            (col1,
    13             col2))
    14       LOCATION ('test.dat'))
    15  REJECT LIMIT UNLIMITED
    16  /
    Table created.
    scott@ORA92> SELECT * FROM test_tab
      2  /
          COL1 COL2
             1 a
             2 b
    scott@ORA92> "Or is there a way to prevent the log from being written to every time it's accessed?"
    You can use NOLOGFILE as an access parameter to prevent it from being written to, as shown below.
    scott@ORA92> CREATE OR REPLACE DIRECTORY mydir AS 'c:\oracle'
      2  /
    Directory created.
    scott@ORA92> CREATE TABLE test_tab
      2    (col1 NUMBER,
      3       col2 VARCHAR2(4))
      4  ORGANIZATION external
      5    (TYPE ORACLE_LOADER
      6       DEFAULT DIRECTORY mydir
      7       ACCESS PARAMETERS
      8         (RECORDS DELIMITED BY NEWLINE
      9          BADFILE 'MYDIR':'test_bad.bad'
    10          NOLOGFILE
    11          FIELDS TERMINATED BY ","
    12            (col1,
    13             col2))
    14       LOCATION ('test.dat'))
    15  REJECT LIMIT UNLIMITED
    16  /
    Table created.
    scott@ORA92> SELECT * FROM test_tab
      2  /
          COL1 COL2
             1 a
             2 b
    scott@ORA92> "Is there a way to have the log written only when an error occurs?"
    Not that I know of, but that does not mean that somebody else doesn't know how or isn't able to figure out a way. If you do find a way, please post it for the benefit of the rest of us.

  • How to implement row level security using external tables

    Hi All Gurus/ Masters,
    I want to implement row level security using external tables, as I'm not sure how to implement that. and I'm aware of using it by RPD level authentication.
    I can use a filter condition in my user level so that he can access his data only.
    But when i have 4 tables in external tables
    users
    groups
    usergroups
    webgrups
    Then in which table I need to give the filter conditions..
    Pl let me know this ...

    You pull the Group into a repository variable using a session variable init block, then reference that variable in the data filters either in the LTS directly or in the security management as Filters. You reference it with the syntax VALUEOF("NQ_SESSION.Variable Name")
    Hope this helps

  • Selecting only required number of rows in an external table

    Hi,
    I have an external table with many flat files as source.. I know I can skip rows using the keyword 'SKIP'. I want to select only first 'n' rows from all the flat files as the rows available in my oracle external table. Is this Possible?...
    eg..
    Flat file 1
    c1,c2
    123,45
    132,56
    'ahgh',34
    'dfd',22
    Flat file 2
    c1,c2
    56,1212
    545,45
    'ahcsd',4
    'dds',24
    I want to create a file which contains the rows, means only the 2nd and 3rd rows from each flat files
    123,45
    132,56
    56,1212
    545,45
    Thanks in Advance
    Poulose

    If this means selecting from all these flat files at the same time then it might get a bit cumbersome. Basically you will have to create an external table for each flat file and then do something like this:
    SELECT * FROM
      ( select c1, c2 from
         ( select c1, c2, rownum as rn from ext_table_1 )
        where rn in (2, 3)
       union all
        select c1, c2 from
         ( select c1, c2, rownum as rn from ext_table_2 )
        where rn in (2, 3)
       union all
      select c1, c2 from
         ( select c1, c2, rownum as rn from ext_table_3 )
        where rn in (2, 3)
       union all
    /Cheers, APC

  • External table and discarded rows

    I need to load a table mapping an external table.
    Sometimes some rows are discarded due to constraints violation or bad values in the file.
    How is it possible to identify the discarded rows?
    Is it possible to automatically create a file containing the
    discarded records?
    Thanks, Gio.

    Before specify a location, you have to create/define directories in the database and set permissions on them.
    Add the location(s) to OWB and register them.
    Right click on the external table, choose CONFGURE.
    Navigate to ACCESS SPECIFICATION. set the locations here.

  • External table - bad row - Please help

    Hi,
    I have one external table which is associated with a LOAN.DAT file.
    If some rows are bad means external table is dumping a bad file with
    the 'bad row' in .bad file. Is there any way to identify what is the reason for
    this or which column caused the row to be bad?
    Regards,
    Mathew Collins.

    Hi Mathew,
    Is there any way to identify what is the reason for this or which column caused the row to be bad?
    Not that know of. I usually just carefully inspect the row and compare it with the format mask:
    I have a reproduceable example, here, this might help:
    http://www.dba-oracle.com/art_ext_tabs.htm
    Hope this helps. . .
    Don Burleson
    Oracle Press author

  • Is there a way to know how many rows were rejected using external tables?

    Hi,
    I'm developing a package that needs to load different kinds of text files into the DB.
    I was wondering whether there's a way of knowing in SQL or PL/SQL how many rows were rejected if my external table is defined with "reject limit unlimited".
    I'm using the external tables in "insert into ... (select ... from external_table where...)"
    sql%rowcount returns the number of inserted rows
    I was hoping for something similar/easy to get the number of rejected rows as well.
    I know I can try to analyze the bad file for the number of records if there's no other way...
    Thanks in advance.

    Pyrocks wrote:
    I was afraid of this answer...
    this is a certain "no there's no other way" or should i wait for other responses (no disrespect - just want to make sure :) )Well the difference would be that this external table will have no complex logic. You would simple read in all the lines from the bad file. The chances that this is broken are therefore very slim compared with your original external table.
    And tehre are many other ways possible. For example you can first copy the file into a real internal (temp) table without using any processing logic but with using an external table. Then do the processing / logic checking of the data and move the data from this temp table into your final data structure. Since you move the data two times the whole process will be slower then the original version.

  • How to import tab delimited using external table?

    Hi all,
    I'm using external table to import data from a tab delimited file. However, I keep getting an error message. I used both TERMINATED BY OX'09' and X'09' but still could not get it work.
    Does anyone know how to solve this problem?
    Thank you very much.

    Hi
    Try this:
    import datafile="/myfiles/mydata" out=mydata dbms=tab replace delimiter='&' getnames=yes
    run;
    Thanks

  • 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 numbers (decimal and scientific notation format)

    Hi all, I need to load inside an external table records that contain 7 fields. The last field is called AMOUNT and it's represented in some records with the decimal format, in others records with the scientific notation format as, for example, below:
    CY001_STATU;2009;Jan;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Jan;11200100;'60800;CYZ900;41380,77
    The External table's script is the following:
    CREATE TABLE HYP_DATA
    COUNTRY VARCHAR2(50 BYTE),
    YEAR VARCHAR2(20 BYTE),
    PERIOD VARCHAR2(20 BYTE),
    ACCOUNT VARCHAR2(50 BYTE),
    DEPT VARCHAR2(20 BYTE),
    ACTIVITY_LOC VARCHAR2(20 BYTE),
    AMOUNT VARCHAR2(50 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY HYP_DATA_DIR
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY NEWLINE
    BADFILE 'HYP_BAD_DIR':'HYP_LOAD.bad'
    DISCARDFILE 'HYP_DISCARD_DIR':'HYP_LOAD.dsc'
    LOGFILE 'HYP_LOG_DIR':'HYP_LOAD.log'
    SKIP 0
    FIELDS TERMINATED BY ";"
    MISSING FIELD VALUES ARE NULL
    REJECT ROWS WITH ALL NULL FIELDS
    "COUNTRY" Char,
    "YEAR" Char,
    "PERIOD" Char,
    "ACCOUNT" Char,
    "DEPT" Char,
    "ACTIVITY_LOC" Char,
    "AMOUNT" Char
    LOCATION (HYP_DATA_DIR:'Total.txt')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;
    If, for the field AMOUNT I use the datatype VARCHAR (as above), the table is loaded but I have some records rejected, and all these records contain the last field AMOUNT with the scientific notation as:
    CY001_STATU;2009;Jan;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Feb;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Mar;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Dec;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    All the others records with a decimal AMOUNT are loaded correctly.
    So, my problem is that I NEED to load all the records (with the decimal and the scientific notation format) together (without records rejected), but I don't know which datatype I have to use for the AMOUNT field....
    Anybody has any idea ???
    Any help would be appreciated
    Thanks in advance
    Alex

    @OP,
    What version of Oracle are you using?
    Just cut'n'paste of you script and example woked FINE for me.
    however my quation is... An external table will LOAD all data or none at all. How are you validating/concluding that...
    I have some records rejected, and all these records contain the last field AMOUNT with the scientific notation
    select * from v$version where rownum <2;
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    select * from mydata;
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Feb     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11200100     '60800     CYZ900     41380,77
    CY001_STATU     2009     Mar     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Dec     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11200100     '60800     CYZ900     41380,77MYDATA table script is...
    drop table mydata;
    CREATE TABLE mydata
    COUNTRY VARCHAR2(50 BYTE),
    YEAR VARCHAR2(20 BYTE),
    PERIOD VARCHAR2(20 BYTE),
    ACCOUNT VARCHAR2(50 BYTE),
    DEPT VARCHAR2(20 BYTE),
    ACTIVITY_LOC VARCHAR2(20 BYTE),
    AMOUNT VARCHAR2(50 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY IN_DIR
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY NEWLINE
    BADFILE 'IN_DIR':'HYP_LOAD.bad'
    DISCARDFILE 'IN_DIR':'HYP_LOAD.dsc'
    LOGFILE 'IN_DIR':'HYP_LOAD.log'
    SKIP 0
    FIELDS TERMINATED BY ";"
    MISSING FIELD VALUES ARE NULL
    REJECT ROWS WITH ALL NULL FIELDS
    "COUNTRY" Char,
    "YEAR" Char,
    "PERIOD" Char,
    "ACCOUNT" Char,
    "DEPT" Char,
    "ACTIVITY_LOC" Char,
    "AMOUNT" Char
    LOCATION (IN_DIR:'total.txt')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;vr,
    Sudhakar B.

  • 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?

Maybe you are looking for

  • Two PR Line items for the TAB Item category

    Hi, We have created a sales order with TAB item category. In MD04 we found two line items of the same firmed PR. Any idea why two lines of PR are generated? Regards, Vengat

  • Meaning of ";1" beside table name in Field Explorer

    Hi, We  can see the data source such as table name in Field Explorer under "Database Fields". Now what does it mean if there is something like this in the table name: "TableName;1" what does ";1" mean? Thanks, Edited by: MKhair on Jun 17, 2011 6:45 P

  • Change of user

    Hi, I've recently purchased a second-hand Palm Z22 and have already used it to store data. When I went on my pc to synchronize I found there was already a user there. I have set up a new username but all the info is stored under the old username. How

  • Oracle Database 10g Integration with SMS gateway

    Dears my company system should integrate with SMS gateway to send the customer SMS, actually i haven't any information about Database Integration methods in general(first time to do that) and In particular about SMS gateway Please help ASAP and try t

  • Recovery partition delete by mistake how can i get it back?

    Hello  I decided to create recovery discs for my hp envy 17, and try to do it by cyberlink , unfortunately i delete amy recovery partition file (it's about 300mb file in disc D:/ ) so pleas help me to download that file Thank you