Filter data on GUI SQL Loader of 10g

I have a 10g and using the SQL developer to import data from an excel to a table.
after right click on the table and specify the file, i have to map the column, since there is no header info in the spreadsheet.
i then came into 2 problems
1) on column with data type, it will say the data is null or invalid format.
2) only a subset of the data in the sheet is needed, so, i like to place a where clause type criteria during the import.
how to i handle these two situations? is there step by step instructions to follow on each?
thanks.

Your problem is most likely in decode - the return type in your expression will be character based on first search value ('null'), so it will be implicitly converted to character and then again implicitly converted to date by loading into date column. At some of this conversions you probably are loosing your time part. You can try instead use cast:
SQL> desc t
Name                                      Null?    Type
LASTWRITTEN                                        DATE
CREATEDON                                          DATE
LASTUPDATEDON                                      DATE
SQL> select * from t;
no rows selected
SQL> !cat t.ctl
LOAD DATA
INFILE *
INTO TABLE T
TRUNCATE
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
LASTWRITTEN
"decode(:LASTWRITTEN,'null',cast(Null as date),
  to_date(:LASTWRITTEN,'YYYY-MM-DD HH24:MI:SS'))",
CREATEDON
"decode(:CREATEDON,'null',cast(Null as date),
  to_date(:CREATEDON,'YYYY-MM-DD HH24:MI:SS'))",
LASTUPDATEDON
"decode(:LASTUPDATEDON,'null',cast(Null as date),
  to_date(:LASTUPDATEDON,'DD/MM/YYYY HH24:MI:SS'))"
BEGINDATA
2007-02-15 15:10:20,null,null
null,2007-02-15 15:10:20,null
null,null,15/02/2007 15:10:20
SQL> !sqlldr userid=scott/tiger control=t.ctl log=t.log
SQL*Loader: Release 10.2.0.3.0 - Production on Fri Feb 29 00:20:07 2008
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Commit point reached - logical record count 3
SQL> select * from t;
LASTWRITTEN         CREATEDON           LASTUPDATEDON
15.02.2007 15:10:20
                    15.02.2007 15:10:20
                                        15.02.2007 15:10:20Best regards
Maxim

Similar Messages

  • SQL Loader Oracle 10g problem in upload date with time data -- Very urgent.

    Hi
    I am trying to upload data using SQL loader. There are three columns in the table
    defined as DATE. When I tried upload a data like this '2007-02-15 15:10:20', it is not loading time part. The date stored as 02/15/2008' only. There is not time on that. I tried with many different format nothing work. Can please help me ?
    I have also tried with to_date --> to_timestamp it did not work.
    The application is going to be in production, I cannot change DATE to TIME STAMP. This is very urgent.
    LASTWRITTEN "decode(:LASTWRITTEN,'null',Null, to_date(:LASTWRITTEN,'YYYY-MM-DD HH24:Mi:SS'))",
    CREATEDON "decode(:CREATEDON,'null',Null, to_date(:CREATEDON,'YYYY-MM-DD HH24:Mi:SS'))",
    LASTUPDATEDON(21) "decode(:LASTUPDATEDON,'null',Null, to_date(:LASTUPDATEDON(21),'DD/MM/YYYY HH24:MI:SS'))"

    Your problem is most likely in decode - the return type in your expression will be character based on first search value ('null'), so it will be implicitly converted to character and then again implicitly converted to date by loading into date column. At some of this conversions you probably are loosing your time part. You can try instead use cast:
    SQL> desc t
    Name                                      Null?    Type
    LASTWRITTEN                                        DATE
    CREATEDON                                          DATE
    LASTUPDATEDON                                      DATE
    SQL> select * from t;
    no rows selected
    SQL> !cat t.ctl
    LOAD DATA
    INFILE *
    INTO TABLE T
    TRUNCATE
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
    LASTWRITTEN
    "decode(:LASTWRITTEN,'null',cast(Null as date),
      to_date(:LASTWRITTEN,'YYYY-MM-DD HH24:MI:SS'))",
    CREATEDON
    "decode(:CREATEDON,'null',cast(Null as date),
      to_date(:CREATEDON,'YYYY-MM-DD HH24:MI:SS'))",
    LASTUPDATEDON
    "decode(:LASTUPDATEDON,'null',cast(Null as date),
      to_date(:LASTUPDATEDON,'DD/MM/YYYY HH24:MI:SS'))"
    BEGINDATA
    2007-02-15 15:10:20,null,null
    null,2007-02-15 15:10:20,null
    null,null,15/02/2007 15:10:20
    SQL> !sqlldr userid=scott/tiger control=t.ctl log=t.log
    SQL*Loader: Release 10.2.0.3.0 - Production on Fri Feb 29 00:20:07 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 3
    SQL> select * from t;
    LASTWRITTEN         CREATEDON           LASTUPDATEDON
    15.02.2007 15:10:20
                        15.02.2007 15:10:20
                                            15.02.2007 15:10:20Best regards
    Maxim

  • Export data ready for sql loader

    Hi,
    I need to export some data from my database ready to be used by sql loader ... what are tools can I use? Using sqlplus (i.e. spool file.csv select c1||";"||c2||";" from table; spool off) is the only tool I can use?

    Hello,
    You have multiple choices depending upon your oracle version on both source and target.
    *1. Conventional export/import (no need to generate csv)*
    *2. Datapump (10g)*
    *3. Extracting .csv file using sql and loading using sqlldr*
    *4. External table unloading data using datapump.*
    *5. External table using .csv file generated via sql script.*
    Regards

  • How to load date column using sql loader

    Hi,
    I am trying to load a file using sql loader. my date value in the file is '2/24/2009 8:23:05 pm',
    In control file for this column i specified like this
    rec_date date ''mm/dd/yyyy hh:mi:ss pm"
    But i am getting following error
    not avalid month.
    Thanks
    sudheer

    Hi,
    Use this example as reference:
    CTL file:
    LOAD DATA
    INFILE 'test.txt'
    BADFILE 'test.bad'
    truncate INTO TABLE T3
    FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '|' TRAILING NULLCOLS
    dt_date DATE "mm/dd/yyyy hh:mi:ss pm")DAT file:
    2/24/2009 8:23:05 pm
    C:\ext_files>sqlldr hr/hr control=test.ctl
    SQL*Loader: Release 10.2.0.1.0 - Production on Wed Jul 1 20:35:35 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 1
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> desc t3;
    Name    Type Nullable Default Comments
    DT_DATE DATE Y                        
    SQL> select to_char(dt_date, 'mm/dd/yyyy hh24:mi:ss') from t3;
    TO_CHAR(DT_DATE,'MM/DD/YYYYHH2
    02/24/2009 20:23:05
    SQL> Regards,
    Edited by: Walter Fernández on Jul 1, 2009 8:35 PM - Adding example...
    Edited by: Walter Fernández on Jul 1, 2009 8:38 PM
    Edited by: Walter Fernández on Jul 1, 2009 8:41 PM - Fixing some information...

  • How to handle Multiple date formats for the same date field in SQL*Loader

    Dear All,
    I got a requirement where I need to get data from a text file and insert the same into oracle table.
    I am using SQL*Loader to populate the data from the text file into my table.
    The file has one field where I am expecting date date data in multiple formats, like dd/mon/yyyy, yyyy/dd/mon, yyyy/mon/dd, ,mm/dd/yyyy, mon/dd/yyyy.
    While using SQL*Loader, I can see Loading is failing for records where we have formats like yyyy/dd/mon, yyyy/mon/dd, mon/dd/yyyy.
    Is there any way in SQL*Loader where we can mention all these date formats so that this date data should go smoothly into the underlying date column in the table.
    Appreciate your response on this.
    Thanks,
    Madhu K.

    The point being made was, are you sure that you can uniquely identify a date format from the value you receieve? Are you sure that the data stored is only of a particular limited set of formats?
    e.g. if you had a value of '07/08/03' how do you know what format that is?
    It could be...
    7th August 2003 (thus assuming it's DD/MM/RR format)
    or
    8th July 2003 (thus assuming it's MM/DD/RR format)
    or
    3rd August 2007 (thus assuming it's RR/MM/DD format)
    or
    8th March 2007 (thus assuming it's RR/DD/MM format)
    or even more obscurely...
    3rd July 2008 (MM/RR/DD)
    or
    7th March 2008 (DD/RR/MM)
    Do you have any information to tell you what formats are valid that would allow you to be specific and know what date format is meant?
    This is a classic example of why dates should be stored on the database using DATE datatype and not VARCHAR2. It can lead to corruption of data, especially if the date can be entered in any format a user wishes.

  • Need to Skip the fields duaring the data upload by SQL*Loader.

    Hi all,
    I am not able to get how to skip some fileds in the file while uploading it thru SQL*Loader. Let us have a look the below scenario.
    The table has 4 columns. but in the input file came up with 6 fields. Let us assume the four fields came as first in the order. Then, we can populate the data into the 4 columns of the table. At the same time we want to skip the remaining fields. Even those fields/columns are no longer available in the database table.
    For example:
    create table data_temp(sno number,name varchar2(10 char),sex char(1),loc varchar2(20 char));
    Data file
    sno,name,sex,loc,organization,contact
    1,ram,M,India,HP,998976789
    2,Shesha,M,India,IBM,7890808098
    Control_file
    OPTIONS(SKIP=1)
    LOAD DATA
    INFILE *
    APPEND INTO TABLE data_temp
    FIELDS TERMINATED BY ',' optionally enclosed by '"'
    TRAILING NULLCOLS
    sno "trim(:sno)",
    name "SUBSTR(trim(:name),1,20)" ,
    sex "SUBSTR(trim(:sex),1,1)",
    loc "SUBSTR(trim(:loc),1,20)" ,
    Please suggest me how to implement the above scenario in the control file.
    Thanks in Advance!!
    Regards,
    Vissu.....

    Use FILLER. Control file:
    OPTIONS(SKIP=1)
    LOAD DATA
    INFILE *
    APPEND INTO TABLE data_temp
    FIELDS TERMINATED BY ',' optionally enclosed by '"'
    TRAILING NULLCOLS
    sno "trim(:sno)",
    name "SUBSTR(trim(:name),1,20)" ,
    sex "SUBSTR(trim(:sex),1,1)",
    loc "SUBSTR(trim(:loc),1,20)" ,
    organization filler,
    contact filler
    begindata
    sno,name,***,loc,organization,contact
    1,ram,M,India,HP,998976789
    2,Shesha,M,India,IBM,7890808098
    {code}
    Now:
    {code}
    SQL> create table data_temp(sno number,name varchar2(10 char),sex char(1),loc varchar2(20 char));
    Table created.
    SQL> host sqlldr scott/tiger control=c:\temp\vissu.ctl log=c:\temp\vissu.log
    SQL> select * from data_temp
      2  /
           SNO NAME       S LOC
             1 ram        M India
             2 Shesha     M India
    SQL>
    {code}
    SY.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Dual Language Data upload using SQL*Loader

    I have to load data consisting of English and Traditional Chinese characters into 8.1.5 from external files. These external files are in MS Excel.
    Is there any way that I can user SQL*Loader for this ? If yes, how ? If not, is there any other way out.
    The NLS in the database is currently AMERICAN.
    null

    ORA-00604 error occurred at recursive SQL level string
    Cause: An error occurred while processing a recursive SQL statement (a statement applying to internal dictionary tables).
    Action: If the situation described in the next error on the stack can be corrected, do so; otherwise contact Oracle Support Services
    This kind of error occurs when data dictionary is
    query a lot.
    Joel P�rez

  • Load Xml Data in oracle (SQL LOADER)

    i have written a sql loader script given below....
    load data
    infile 'contact1.xml' "str '</CONTACT>'"
    truncate
    into table XmlTest
    dummy filler terminated by ">",
    Location_id enclosed by "<Location_id>" and "</Location_id>",
    fname enclosed by "<fname>" and "</fname>",
    lname enclosed by "<lname>" and "</lname>"
    the content of the contact1.xml is given below.....
    <CONTACT>
    <Location_id>1</Location_id>
    <fname>Robert</fname>
    <lname>Jones</lname>
    </CONTACT>
    <CONTACT>
    <Location_id>1</Location_id>
    <fname>Robert</fname>
    <lname>Jones</lname>
    </CONTACT>
    the script works fine for the given xml... but if one of the tag in the xml is changed to below syntax....
    <CONTACT Location_id="1">
    <fname>Robert</fname>
    <lname>Jones</lname>
    </CONTACT>
    <CONTACT Location_id="1">
    <fname>Robert</fname>
    <lname>Jones</lname>
    </CONTACT>
    what modification is required in the script to read such xml...Kindly Help!!

    And in what way does this relate to SQL and PL/SQL?
    There is a demo of loading XML in Morgan's Library under SQL*Loader.
    But as your question is off-topic here ... if the demo does not help you please continue this by starting a thread in the correct forum: Database General.
    Thanks.

  • Date datatype in SQL*LOADER

    Hi guys,
    How do we use DATE datatype in SQL*LOADER

    Hi,
    I was just wondering if you've resolved this error. I want to know because we're experiencing the exact same error right now.
    Thanks.
    Regards,
    _lilim

  • Date Format in SQL Loader

    Dear All,
    I have a table CMS_HO where I have defined different columns. One column is of date type STATUS_DATE. I want to upload one ASCII file where one field is in the format like below:
    5/26/2008 12:41
    5/26/2008 8:51
    5/28/2008 9:01
    5/28/2008 13:54
    5/13/2008 10:45
    4/6/2008 9:21
    I want to upload file into Oracle database. Currently I am using following control file:
    LOAD DATA
    INTO TABLE CMS_HO TRUNCATE
    FIELDS TERMINATED BY "\t"
    TRAILING NULLCOLS
    ( ID,EXPIRYDATE, VER, SN, STATUS_DATE)
    There seems error in the STATUS_DATE field in control file. Can any one help how to modify this Control file so that data against this field can be uploaded into date format please?
    Thanks

    Here's an example i pulled from the web on specifying the date format in a control file.
    http://infolab.stanford.edu/~ullman/fcdb/oracle/or-load.html#loading%20date%20data
    Based on the sample data you provided, i think this is the format you're after.
    ME_XE?select
      2     to_date('5/13/2008 10:45', 'mm/dd/yyyy hh24:mi') as date_value_24_hours
      3  from dual;
    DATE_VALUE_24_HOURS
    13-MAY-2008 10 45:00
    1 row selected.
    Elapsed: 00:00:00.89

  • New Line in data file for sql loader

    Hi all,
    I have a requirement to load a data file in which some of the rows are in new line as given in following example. If i put a '\n' character in control file, then it will load only those records which have newline in them ignoring non new line ones. please have a look at control fileand provide a solution to it :-
    32 grand street ~NY~NY
    42 riverdrive,
    apt 1B ~PL~TX
    Richardson road
    apt 32~ SF ~CA
    As you see there are newline characters in record 2 and 3, right now my control file looks like this -
    LOAD DATA
    INFILE 'example.txt' "STR '\r\n'"
    INTO TABLE "temp_table"
    INSERT
    FIELDS TERMINATED BY '~'
    TRAILING NULLCOLS
    (ADDRESS1,
    CITY,
    STATE)
    If i remove "STR '\r\n'" , then the data gets loaded into different rows like the third record looks like this -
    ADDRESS                         CITY                     STATE
    Richardson road null null
    apt 32 SF CA
    Please help.

    Your requirement is very unclear.
    Is this your INPUT ?
    --record 1
    32 grand street ~NY~NY
    --record 2
    42 riverdrive, --"NL"
    apt 1B ~PL~TX
    --record 3
    Richardson road --"NL"
    apt 32~ SF ~CAIs this your OUTPUT?
    ADDRESS      CITY STATE
    32 grand street NY   NY
    42 riverdrive,     null null
    apt 1B          PL   TX
    Richardson road null null
    apt 32           SF   CAAre you using Linux or Windows platform?
    You should have only one record terminator character.
    *\r\n* is Windows The End of Line character (The Carriage Return + The Line Feed).
    "STR '\r\n'" = "str X'0D0A'"
    If there is no data after \r\n, columns will be null.
    http://docs.oracle.com/cd/B28359_01/server.111/b28319/ldr_concepts.htm#i1005800

  • SQL Loader in 10g

    friends!
    I have a flat file which have 15.millions rows i want to load into one column.
    Flat_File data: (column is seprated with whitespace)
    ============
    002785 034730 060844 092119 122773 156571 187202 215782 247631 284387 318394
    003954 035668 061259 093536 123226 156821 187359 216236 247671 285459 320328
    004158 035850 061936 095732 123781 156914 187398 216486 247812 286778 321040
    006266 036901 063092 095806 124212 157854 187438 216984 247842 288170 321091
    007410 037302 063734 096094 124651 158284 187550 217155 247851 289318 321691
    008221 037305 064672 096225 124902 160042 187630 219078 249494 289769 321820
    008224 038034 065257 096424 125120 160771 188022 219280 250780 290550 322542
    008518 041087 065741 096428 126239 161142 188298 219432 252114 291187 323677
    008745 042247 066896 096904 126442 162487 189250 221793 252248 292013 324738
    008754 042572 067033 096974 127424 162865 190203 221929 252637 292613 324948
    008852 042979 067665 097285 129122 163565 190577 224002 253291 293639 325252
    Control Files
    ============
    load data
    infile 'draws_2009.txt'
    discardfile 'bad_records.txt'
    insert
    into table DRAW_LIST
    fields terminated by ' '
    (bond_number)
    After running its loading just one column of the flat file. i want to load all columns data into one column.
    Waiting !!!

    I think still you are some missing in my requirement. Suppose, i have eight values now i want to insert into a single column of the table.
    4424 4442 2441 5455
    4345 6786 7686 6788
    Errors are as follow:
    ==============
    Table DRAW_LIST, loaded from every logical record.
    Insert option in effect for this table: INSERT
    Column Name Position Len Term Encl Datatype
    BOND_NUMBER FIRST * , CHARACTER
    Record 55: Rejected - Error on table DRAW_LIST, column BOND_NUMBER.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    any help ?

  • How to get Dynamic data file in SQL*Loader?

    Hi all,
    I have a requirement that needs to import data everyday using background process. I have created a control file with the fixed datafile name and calling it through java. It is working fine.
    The thing is data file name is not constant, it changes everyday (I mean the file name format is YearMonthDate_Clients.cvs). But the the data file location is fixed location.
    How can I get the data file name dynamically?
    Can someone has the answer?
    Thanks in advance,
    Kalyogi

    I'm not a JAVA developer, but I've used this before
    File folder = new File("c:/");
        File[] listOfFiles = folder.listFiles();
        for (int i = 0; i < listOfFiles.length; i++) {
          if (listOfFiles.isFile()) {
    --Here the filename is printed, but I'm sure you can pass this to whatever/however you are invoking SqlLdr
    System.out.println("File " + listOfFiles[i].getName());

  • Given data is (10,20,.,30)how to load the data  from flat file to base table by eliminate the dot from data by using sql loader

    pls send ans for this

    1b5595eb-fcfc-48cc-90d2-43ba913ea79f wrote:
    pls send ans for this
    use any text editor to eliminate the dot before loading

  • SQL Loader error while loading a date field

    Hi,
    I am getting the below error while I am trying to load a table with a date field using SQL Loader
    Record 1: Rejected - Error on table RPT_HOST_USAGE, column USAGE_TIMESTAMP.
    ORA-01861: literal does not match format string
    My input file is as below
    <code>
    Host_Usage_ID,Host_ID,Technology_ID,Environment_ID,Usage_Timestamp,Avg_CPU_Pct,Avg_Memory_MB,CPU_Spike
    1,12,1,8,'2009-08-01 00:00:00',0.000000000,23875.000000000,0.000000000
    <code>
    My Loader.ctl is
    <code>
    OPTIONS (SKIP=1)
    load data
    infile 'C:\rpt_Host_Usage.txt'
    into table RPT_HOST_USAGE
    fields terminated by ","
    HOST_USAGE_ID,
    HOST_ID,
    TECHNOLOGY_ID,
    ENVIRONMENT_ID,
    USAGE_TIMESTAMP,
    AVG_CPU_PCT,
    AVG_MEMORY_MB,
    CPU_SPIKE
    <code>
    I have tried options like USAGE_TIMESTAMP TO_DATE(USAGE_TIMESTAMP,'YYYY-MM-DD HH24:MI:SS') but didn't work...
    Can you please tell me how to resolve this issue?
    Any pointers on this will be helpful
    Thanks
    Mahesh

    I went back and looked at some of my old *.ctl files and I did something simlilar to what you mentioned and it worked for me, but I had surrounded the option in double-quotes and included a colon in front of the item. Example:
    TECHNOLOGY_ID,
    ENVIRONMENT_ID,
    USAGE_TIMESTAMP "to_date(:USAGE_TIMESTAMP,'YYYY-MM-DD HH24:MI:SS')",
    AVG_CPU_PCT,
    AVG_MEMORY_MB,
    ....

Maybe you are looking for