Selective load in external table

Hi all,
I need to load data into my external table based on conditions. If i use the 'load when' im able to load the data into the table but my requirement is to load data into different columns of the same table based on the conditional "when" clause.
This is equivalent to wht we do in .ctl file using loader..Th scenario being:
LOAD DATA     
INFILE '/m018/applmgr/ERP1/modap/1.0.0/bin/BNKSTMT260508.txt'                                   
APPEND
INTO TABLE                                   
MODAP_IN_BNK_RECON_TBL     
WHEN record_type = '01'
FIELDS TERMINATED BY ','                              
OPTIONALLY ENCLOSED BY '"'                              
TRAILING NULLCOLS                                   
(RECORD_TYPE POSITION(1)
,SENDER_IDENTI
,RECEIVER_IDENTI
     ,FILE_CREATION_DATE DATE "YYMMDD" NULLIF FILE_CREATION_DATE=BLANKS
     ,FILE_CREATION_TIME
     ,FILE_SEQ_NO
     ,RECORD_LENGTH
     ,BLOCKING_FACTOR
     ,VERSION_NO
INTO TABLE                                   
MODAP_IN_BNK_RECON_TBL     
WHEN record_type = '02'
FIELDS TERMINATED BY ','                              
OPTIONALLY ENCLOSED BY '"'                              
TRAILING NULLCOLS                                   
(RECORD_TYPE POSITION(1) "TRIM(:RECORD_TYPE)"
,RECEIVER_IDENTI "TRIM(:RECEIVER_IDENTI)"
,ORIGINATOR_IDENTI "TRIM(:ORIGINATOR_IDENTI)"
     ,GROUP_STATUS "TRIM(:GROUP_STATUS)"
     ,AS_OF_DATE DATE "YYMMDD" NULLIF AS_OF_DATE=BLANKS
     ,AS_OF_TIME "TRIM(:AS_OF_TIME)"
     ,CURRENCY_CODE "TRIM(:CURRENCY_CODE)"
I want to replicate the same in external table. Please suggest me a suitable solution for this at the earliest.
Regards,
Balaji V

Here is a sample I used:
DROP TABLE myschema.mytable;
CREATE TABLE myschema.mytable (
"ID" VARCHAR2(12),
"RESP_DOB" DATE,
"RESP_FAM_REL" VARCHAR2(5),
"PET_FIRST_NAME" VARCHAR2(11),
"PET_MIDDLE_NAME" VARCHAR2(11),
"PET_LAST_NAME" VARCHAR2(17),
"PET_SUFFIX" VARCHAR2(1)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY "MY_DIRECTORY"
ACCESS PARAMETERS(
RECORDS DELIMITED BY NEWLINE
BADFILE 'the_BAD.TXT'
DISCARDFILE 'the_DISCARD.TXT'
LOGFILE 'the_LOG.TXT'
FIELDS
MISSING FIELD VALUES ARE NULL
ID POSITION(1:12),
RESP_DOB POSITION(98:105) DATE MASK "mmddyyyy",
RESP_FAM_REL POSITION(106:110) NULLIF RESP_FAM_REL=".",
PET_FIRST_NAME POSITION(111:121) NULLIF PET_FIRST_NAME=".",
PET_MIDDLE_NAME POSITION(122:132) NULLIF PET_MIDDLE_NAME=".",
PET_LAST_NAME POSITION(133:149) NULLIF PET_LAST_NAME=".",
PET_SUFFIX POSITION(150:150) NULLIF PET_SUFFIX="."
LOCATION ('the_file.txt')
);

Similar Messages

  • Error while selecting date from external table

    Hello all,
    I am getting the follwing error while selecting data from external table. Any idea why?
    SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
      2        SE_CUST_ID NUMBER(38),
      3        SE_TRAN_AMT_LCY FLOAT(126),
      4        SE_REVERSAL_MARKER VARCHAR2(255))
      5  ORGANIZATION EXTERNAL (
      6    TYPE ORACLE_LOADER
      7    DEFAULT DIRECTORY ext_tables
      8    ACCESS PARAMETERS (
      9      RECORDS DELIMITED BY NEWLINE
    10      FIELDS TERMINATED BY ','
    11      MISSING FIELD VALUES ARE NULL
    12      (
    13        country_code      CHAR(5),
    14        country_name      CHAR(50),
    15        country_language  CHAR(50)
    16      )
    17    )
    18    LOCATION ('SE2.csv')
    19  )
    20  PARALLEL 5
    21  REJECT LIMIT UNLIMITED;
    Table created.
    SQL> select * from se2_ext;
    SQL> select count(*) from se2_ext;
    select count(*) from se2_ext
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04043: table column not found in external source: SE_REF_NO
    ORA-06512: at "SYS.ORACLE_LOADER", line 19

    It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
    HTH -- Mark D Powell --

  • SQL *Loader and External Table

    Hi,
    Can anyone tell me the difference between SQL* Loader and External table?
    What are the conditions under we can use SQL * Loader and External Table.
    Thanx

    External tables are accessible from SQL, which generally simplifies life if the data files are physically located on the database server since you don't have to coordinate a call to an external SQL*Loader script with other PL/SQL processing. Under the covers, external tables are normally just invoking SQL*Loader.
    SQL*Loader is more appropriate if the data files are on a different server or if it is easier to call an executable rather than calling PL/SQL (i.e. if you have a batch file that runs on a server other than the database server that wants to FTP a data file from a FTP server and then load the data into Oracle).
    Justin

  • SQL Loader versus External Table

    If anyone has worked on external tables please let me know your views.

    user637544 wrote:
    for sqlldr i follow the following approach
    1. truncate table
    2. call sqlldr and load records in staging table
    3. check for bad records
    how do i tuncate, call external table and check bad records for external table.As part of the SQL*Loader control file you can tell it to truncate the table as part of the process before it loads in the data.
    The key differences between SQL*Loader and External Tables are:
    1. SQL*Loader is an external utility run from the o/s command line, whereas External tables are usable from within SQL and PL/SQL.
    2. SQL*Loader can only load data up into the database, whereas External tables can allow you to read files and write files (10g onwards)
    3. SQL*Loader has limited control on skipping rows etc. whereas External tables can be queried using SQL and has all the flexibility that SQL can offer.
    4. SQL*Loader requires connection information to the database, whereas External tables are already part of the database
    5. SQL*Loader can only change the source filename through dynamic o/s level scripts, whereas External tables can have the filename changed using an ALTER TABLE ... LOCATION ... command.
    If you want to truncate your staging table before loading it with data from the external table, then you will just have to do that as a seperate step, because the external table is not associated with other tables. Simply truncate the other table and then query the data from the external table into the staging table.
    External tables offer a lot more flexibility than using SQL*Loader.

  • Sql loader or external table

    Hi all good morning.
    can we write a stored procedure that loads a file into the table using sql loader?
    can Java call the above stored procedure?
    regards
    raj
    Edited by: user10887630 on Apr 23, 2009 6:18 AM

    Are you saying the files themselves can't be located on the server? or just that the process for loading the files can't be located on the server.
    If the files themselves cannot reside on the server then you won't be able to use SQL*Loader or External tables from within stored procedures. It would require some clever Java code type stuff to get across to a.n.other machine where the files are stored and get the data.
    Typically it is normal for such files to be located on the server. What reasons do the DBA's give for not wanting them there?
    DBA's say that application specific files cannot be maintained on the Database serverSo what are all the database data files then? They hold data from the applications. ;)

  • Sql Loader Vs External table? Which one is preffered?

    Hello guru,
    We trying to load the data into about 160 tables. Here are the following things we are doing currently,
    1. We get the flat file in .txt format
    2. We are writing the control file for each flat file for thier respective tables
    3.And we are using sql loader command to load this data into the table.
    I was wondering if this process is cumbersome, and i m not sure if external table could be simple in loading the tables compared to what we are doing ?And i have not used external tables, so wanted to know which on eis better ? So any idea is greatly appriciated !
    FYI.. Version :- Oracle 11g
    Thank you so much!

    Thanks for you reply justin !
    I found the below example for loading the data into external table...
    CREATE OR REPLACE DIRECTORY dat_dir AS 'C:\Oradata\Data';
    CREATE OR REPLACE DIRECTORY log_dir AS 'C:\Oradata\Log';
    CREATE OR REPLACE DIRECTORY bad_dir AS 'C:\Oradata\Bad';
    GRANT READ ON DIRECTORY dat_dir TO scott;
    GRANT WRITE ON DIRECTORY log_dir TO scott;
    GRANT WRITE ON DIRECTORY bad_dir TO scott;
    CREATE TABLE revext (person      VARCHAR2(20),
                         rev_jan     NUMBER(4),
                         rev_feb     NUMBER(4),
                         rev_mar     NUMBER(4),
                         rev_apr     NUMBER(4),
                         rev_mai     NUMBER(4),
                         rev_jun     NUMBER(4),
                         rev_jul     NUMBER(4),
                         rev_aug     NUMBER(4),
                         rev_sep     NUMBER(4),
                         rev_oct     NUMBER(4),
                         rev_nov     NUMBER(4),
                         rev_dez     NUMBER(4))
    ORGANIZATION EXTERNAL
       TYPE ORACLE_LOADER
       DEFAULT DIRECTORY dat_dir
       ACCESS PARAMETERS
         records delimited by newline
         badfile bad_dir:'revext%a_%p.bad'
         logfile log_dir:'revext%a_%p.log'
         fields terminated by ','
         missing field values are null
         ( person,
           rev_jan,
           rev_feb,
           rev_mar,
           rev_apr,
           rev_mai,
           rev_jun,
           rev_jul,
           rev_aug,
           rev_sep,
           rev_oct,
           rev_nov,
           rev_dez
       LOCATION ('revext.dat')
    PARALLEL 4
    REJECT LIMIT UNLIMITED;
    CREATE TABLE revenue (
        person       VARCHAR2(20),
        month        VARCHAR2(3),
        revenue      NUMBER,
        CONSTRAINT revenue_pk PRIMARY KEY (person,month));
    INSERT INTO revenue (person,month,revenue)
       SELECT person,'Jan',rev_jan
       FROM revext--but currently we are using sql loader, our data looks like this
      1119Smith      01/01/1982AXYZ corporation  xyz corp
      1111collen      01/01/1990AABC corporation  abc corp
         and control file is like this
    INTO TABLE "XYZ_tbl"
       ID                     POSITION(01:05)        CHAR                  "DECODE(RTRIM(:ID), NULL, 'NA', :ID)"       ,
       Name                POSITION(06:15)        CHAR                  "DECODE(RTRIM(:NAME), NULL, 'NA', :Name)"   ,
       Act_dt              POSITION(16:25)        DATE                  "MM/DD/YYYY" NULLIF ACT_DT=BLANKS
    My question is, can i use the options like NULLIF/ DECODE or changing datatypes when loading or functions like REPLACE / TO_DATE in External tables ? Any idea? Any example code or SQL will great
    Thank you so much!

  • While loading through External Tables, Japanese characters wrong load

    Hi all,
    I am loading a text file through External Tables. While loading, japanese characters are loading as junk characters. In text file, the characters are showing correctly.
    My spool file
    SET ECHO OFF
    SET VERIFY OFF
    SET Heading OFF
    SET LINESIZE 600
    SET NEWPAGE NONE
    SET PAGESIZE 100
    SET feed off
    set trimspool on
    spool c:\SYS_LOC_LOGIC.txt
    select CAR_MODEL_CD||',' || MAKER_CODE||',' || CAR_MODEL_NAME_CD||',' || TYPE_SPECIFY_NO||',' ||
         CATEGORY_CLASS_NO||',' || SPECIFICATION||',' || DOOR_NUMBER||',' || RECOGNITION_TYPE||',' ||
         TO_CHAR(SALES_START,'YYYY-MM-DD') ||',' || TO_CHAR(SALES_END,'YYYY-MM-DD') ||',' || LOGIC||',' || LOGIC_DESCRIPTION
    from Table where rownum < 100;
    spool off
    My External table load script
    CREATE TABLE SYS_LOC_LOGIC
         CAR_MODEL_CD                         NUMBER               ,
         MAKER_CODE                              NUMBER,
         CAR_MODEL_NAME_CD                    NUMBER,
         TYPE_SPECIFY_NO                         NUMBER               ,
         CATEGORY_CLASS_NO                    NUMBER               ,
         SPECIFICATION                         VARCHAR2(300),
         DOOR_NUMBER                              NUMBER,
         RECOGNITION_TYPE                    VARCHAR2(30),
         SALES_START                          DATE ,
         SALES_END                               DATE ,
         LOGIC                                   NUMBER,
         LOGIC_DESCRIPTION                    VARCHAR2(100)
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY XMLTEST1
    ACCESS PARAMETERS
    RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    MISSING FIELD VALUES ARE NULL
                        CAR_MODEL_CD,MAKER_CODE,CAR_MODEL_NAME_CD,TYPE_SPECIFY_NO,
                        CATEGORY_CLASS_NO,SPECIFICATION,DOOR_NUMBER,RECOGNITION_TYPE,
                        SALES_START date 'yyyy-mm-dd', SALES_END      date 'yyyy-mm-dd',
                        LOGIC, LOGIC_DESCRIPTION     
    LOCATION ('SYS_LOC_LOGIC.txt')
    --location ('products.csv')
    REJECT LIMIT UNLIMITED;
    How to solve this.
    Thanks in advance,
    Pal

    Just so I'm clear, user1 connects to the database server and runs the spool to generate a flat file from the database. User2 then uses that flat file to load that data back in to the same database? If the data isn't going anywhere, I assume there is a good reason to jump through all these unload and reload hoops rather than just moving the data from one table to another...
    What is the NLS_LANG set in the client's environment when the spool is generated? Note that the NLS_CHARACTERSET is a database setting, not a client setting.
    What character set is the text file? Are you certain that the text file is UTF-8 encoded? And not encoded using the operating system's local code page (assuming the operating system is capable of displaying Japanese text)
    There is a CHARACTERSET parameter for the external table definition, but that should default to the character set of the database.
    Justin

  • Error when loading from External Tables in OWB 11g

    Hi,
    I face a strange problem while loading data from flat file into the External Tables.
    ORA-12899: value too large for column EXPIRED (actual: 4, maximum: 1)
    error processing column EXPIRED in row 9680 for datafile <data file location>/filename.dat
    In a total of 9771 records nearly 70 records are rejected due to the above mentioned error. The column (EXPIRED) where the error being reported doesn't have value greater than 1 at all. I suspect it to be a different problem.
    Example: One such record that got rejected is as follows:
    C|234|Littérature commentée|*N*|2354|123
    highlightened in Bold is the EXPIRED Column.
    When I tried to insert this record into the External Table using UTL_FILE Utility it got loaded successfully. But when I try with the file already existing in the file directory it again fails with the above error, and I would like to mention that all the records which have been loaded are not Ok, please have a look at the DESCRIPTION Column which is highlightened. The original information in the data file looks like:
    C|325|*Revue Générale*|N|2445|132
    In the External Table the Description Value is replaced by the inverted '?' as follows:
    Reue G¿rale
    Please help.
    Thanks,
    JL.

    user1130292 wrote:
    Hi,
    I face a strange problem while loading data from flat file into the External Tables.
    ORA-12899: value too large for column EXPIRED (actual: 4, maximum: 1)
    error processing column EXPIRED in row 9680 for datafile <data file location>/filename.dat
    In a total of 9771 records nearly 70 records are rejected due to the above mentioned error. The column (EXPIRED) where the error being reported doesn't have value greater than 1 at all. I suspect it to be a different problem.
    Example: One such record that got rejected is as follows:
    C|234|Littérature commentée|*N*|2354|123
    highlightened in Bold is the EXPIRED Column.
    When I tried to insert this record into the External Table using UTL_FILE Utility it got loaded successfully. But when I try with the file already existing in the file directory it again fails with the above error, and I would like to mention that all the records which have been loaded are not Ok, please have a look at the DESCRIPTION Column which is highlightened. The original information in the data file looks like:
    C|325|*Revue Générale*|N|2445|132
    In the External Table the Description Value is replaced by the inverted '?' as follows:
    Reue G¿rale
    Please help.
    Thanks,
    JL.sorry, couldnt see the highlighted test.could you plesae enclsoe it in  tags
    also post the table definition with attributes. BTW..Whats your NLS_LANGUAGE SET TO?

  • Problem while selecting data from external tables

    Hi All,
    I am facing a problem with external tabels. I have created an external table
    create table ext_org_table
    ( id varchar2(10)
    , name varchar2(100)
    ,id_parent varchar2(10)
    ,name_parent varchar2(100))
    organization external
    ( type oracle_loader
    default directory MYDIR
    access parameters
    records delimited by newline
         nologfile
         nobadfile
    fields terminated by ','
    missing field values are null
    location ('Orgdata.csv')
    reject limit unlimited;
    The problem is that when i give select * from ext_org_table , i get following error
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04040: file Orgdata.csv in MYDIR not found
    ORA-06512: at "SYS.ORACLE_LOADER", line 19
    ORA-06512: at line 1
    Now , i have file Orgdata.csv in the specified directory.
    I have created directory in oracle using create directory command.
    I have granted read,write permission on the directory to user.
    I have given all read,write and execute permissions to folder where my files resides.My file resides in /appl/home/kk
    Now i don't understand why it is giving error file in Mydir not found.
    Kindly suggest.
    Regards
    Krish

    Hi,
    You are obviously doing someting wrong.
    May be the direcotry is not present or may be the file is not rpesent in the directory.
    I just tried ths
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    Connected as SYS
    create directory mydir as 'c:\csv';
    grant read,write on directory mydir to scott;From Scott
    create table ext_org_table
    ( id varchar2(10)
    , name varchar2(100)
    ,id_parent varchar2(10)
    ,name_parent varchar2(100))
    organization external
    ( type oracle_loader
    default directory MYDIR
    access parameters
    records delimited by newline
    nologfile
    nobadfile
    fields terminated by ','
    missing field values are null
    location ('Orgdata.csv')
    reject limit unlimited;
    select * from ext_org_table;Ofcourse i made up some dummy data to test and its all OK.
    again,
    You may want to check if
    1) If the directory exists (select * from all_directories where directory_name='MYDIR');
    2) If the user has the read/write permissions on that directory
    3) If the file orgdata exists in that directory.
    Regards,
    Bhushan

  • Selecting data from external table

    Hi there
    I was wondering if somebody could assist me. When I try to select data from an external table, no data is displayed, and in my log file I receive the following error:
    KUP-04026: field too long for datatype. Please find attached my external table script.
    CREATE TABLE DEMO_FILE_EXT
    MACODE               NUMBER(7),
    MANO                    NUMBER(7),
    DEPNO                    VARCHAR2(2 BYTE),
    DEPTYPE                    NUMBER(5),
    STARTDATE               NUMBER(8),
    ENDDATE               NUMBER(8),
    OPTIONSTART               NUMBER(8),
    BENEFITSTART     NUMBER(8),
    STARTSUSPEND          NUMBER(8),
    ENDSUSPEND          NUMBER(8),
    INITIALS          VARCHAR2(5 BYTE),
    FIRSTNAME          VARCHAR2(20 BYTE),
    SURNAME                    VARCHAR2(25 BYTE),
    STR1                    VARCHAR2(30 BYTE),
    STR2                    VARCHAR2(30 BYTE),
    STR3                    VARCHAR2(30 BYTE),
    STR4                         VARCHAR2(30 BYTE),
    SCODE                    VARCHAR2(6 BYTE),
    POS1                    VARCHAR2(30 BYTE),
    POS2                    VARCHAR2(30 BYTE),
    POS3                    VARCHAR2(30 BYTE),
    POS4                    VARCHAR2(30 BYTE),
    PCODE                    VARCHAR2(6 BYTE),
    TELH                    VARCHAR2(10 BYTE),
    TELW                    VARCHAR2(10 BYTE),
    TELC                    VARCHAR2(10 BYTE),
    IDNUMBER          VARCHAR2(13 BYTE),
    DOB                NUMBER(8),
    GENDER               VARCHAR2(1 BYTE),
    EMPLOYER_CODE               VARCHAR2(10 BYTE),
    EMPLOYER_NAME               VARCHAR2(900 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY DEMO_FILES
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY newline
         BADFILE 'Tinusb.txt'
         DISCARDFILE 'Tinusd.txt'
         LOGFILE 'Tinusl.txt'
    SKIP 1
    FIELDS TERMINATED BY '|'
              MISSING FIELD VALUES ARE NULL
         (MACODE,
         MANO,
         DEPNO,
         DEPTYPE,
         STARTDATE,
         ENDDATE,
         OPTIONSTART,
         BENEFITSTART,
         STARTSUSPEND,
         ENDSUSPEND,
         INITIALS,
         FIRSTNAME,
         SURNAME,
         STR1,
         STR2,
         STR3,
         STR4,
         SCODE,
         POS1,
         POS2,
         POS3,
         POS4,
         PCODE,
         TELH,
         TELW,
         TELC,
         IDNUMBER,
         DOB,
         GENDER,
         EMPLOYER_CODE,
         EMPLOYER_NAME
    LOCATION (DEMO_FILES:'Test1.txt')
    REJECT LIMIT UNLIMITED
    LOGGING
    NOCACHE
    NOPARALLEL;
    I have the correct privileges on the directory, but the error seems to be on the EMPLOYER_NAME field. The file I try to upload is in pipe-delimited format. The last field in the file does not have a pipe-delimiter at the end. Can this be the problem? Must I go and look for any trailing spaces? Can I specify in the external table script how many characters I need for the employer_name field? We receive this file from an external company
    Thank you very much for the help
    Ferdie

    common mistake, you gave the field sizes in the
    column listing of the table, but not in the file
    definition. oracle does not apply one to the other.
    in the file defintion section, give explict field
    sizes.Hi shoblock
    Sorry for only coming back to you now, thank you for your help, I had to give the explicit field size for the last column (employer name).
    Thank you once again!!
    Ferdie

  • SQL*Loader or external table for load a MSG (email) file

    Hi there!
    I'm looking for a way to load an email in a Oracle DB.
    I mean, not all the email's body in a column, but to "parse" it in a multi column/table fashion.
    Is it possible to do with a sql*loader script or an external table?
    I think it is not possible, and that I must switch to XML DB.
    Any idea?
    Thanks,
    Antonio

    Hello,
    Why don't you just load the entire MSG (email) as clob into one email_body column or whatever column name you want to use.
    To load data upto 32k, you can use varchar2(32656) but its not a good idea to load clob in that manner because it's very inconsistent as length can
    vary resulting in string literal too long. So you have 2 choices now, first you have to use either procedure or anonymous block to load clob data.
    First Method -- I loaded alert.log successfully and you can imagine how big this file can be (5MB in my test case)
    CREATE OR REPLACE DIRECTORY DIR AS '/mydirectory/logs';
    DECLARE
       clob_data   CLOB;
       clob_file   BFILE;
    BEGIN
       INSERT INTO t1clob
       VALUES (EMPTY_CLOB ())
       RETURNING clob_text INTO clob_data;
       clob_file   := BFILENAME ('DIR', 'wwalert_dss.log');
       DBMS_LOB.fileopen (clob_file);
       DBMS_LOB.loadfromfile (clob_data,
                              clob_file,
                              DBMS_LOB.getlength (clob_file)
       DBMS_LOB.fileclose (clob_file);
       COMMIT;
    END;Second Method: Use of Sqlldr
    Example of controlfile
    LOAD DATA
    INFILE alert.log "STR '|\n'"
    REPLACE INTO  table t1clob
       clob_text char(30000000)
    )Hope this helps

  • SQL loader  verses External table

    hi
    Can anybody guide me the advantages of External table over SQL Loader in data warehousing environment.
    Or and any URL where I can find suitabel knowledge.
    Thanks in advance.
    Moloy

    here it is.
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14215/et_concepts.htm#sthref1672

  • Sql loader utl_file & external table

    can any one let me know the differences between.
    1.sql loader
    2.utl_file
    3.external table
    Regards.
    Asif.

    To expand on Aron's answer....
    SQL*Loader - An operating system utility which uses control files (which you create) to load data files onto database tables.
    UTL_FILE - A database package which can be used for reading and writing files in any format you care to design programmatically.
    External Table - The latest thing which can be used instead of SQL*Loader. This is done from the database end, by creating a table as an external table and pointing it at the source file on the operating system. It also allows information similar to that put in the SQL*Loader control files to be specified against the table. By querying against the table you are in fact querying against the source file. There are some limitation compared to regular database tables such as there is no ability to write to the external table.
    ;)

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

  • Selective load into setup table

    Hello,
    Is there any way we can load multiple selections into setup table in OLI7BW. Currently I am only able to load range of values. But i have a list of almost 2000 records and they are not in sequence. And loading one by one requires too much effort. Loading ranges would load millions of records.
    Please advice.
    Regards,
    Tints

    Hi Tinu,
    Pick all 200 0 orders and check in VBAK table for CREATED ON field.
    Down load all 2000 orders into excel and put filter on created on value....then note down all the created on dates.
    Now you can load orders based on created on date. make sure that you are loading the data to DSO as it avoids duplication
    Regards
    SujanR

Maybe you are looking for

  • What is the recommended way to truncate tables in ODI?

    I want to create a separate step to truncate the result tables, before the start of the actual job. What is the recommended way of doing this? I am currently putting the truncate statements in the ODI procedure, but that has a lot of typing. Is there

  • How Can I Put iTunes On My External Hard Drive?

    How Can I Put iTunes On My External Hard Drive? I would like to free up space on my laptop's hard drive by moving iTune onto my external hd. Thanks, Dave

  • Fill datablocks

    Hi I have 3 datablocks, one master table and two detail tables and I now need to only fill the master table when the program starts and fill the other two tables when the user clicks in them, this I have fixed just by comment out most of the code in

  • I want to change my email account

    I want to change my email on my itunes account but it says the address I want to use is my recovery email???

  • Authorizations for report

    hi i have this report employee emp group emp sub group number of employees what steps i need follow at rsa1 what steps i need follow at rsecadmin what setps i need follow at pfcg can i gets tep by step process