SQL Load ORDER BY clause

Does anyone know how or where to enter in the ORDER BY clause when you use a SQL data source in a load rule? I prefer to do the classification in the State of charge rather than create a view on the side of the DB for this if possible.

According to the documentation "box of the SQL statement in Open SQL Data Sources dialog box provides Select, From, and where areas of text that helps you write SQL queries." You can specify multiple data sources, filter the display of folders and specify how the records displayed in the data editor Prep are classified and grouped. "but I have not found anywhere where you can order or group data. I don't need to be able to group data I want to just be able to control my data to make the most effective possible charging process.

I sort the data by inserting into the table of load, but Oracle is not necessarily insert the records in the table according to their order when you go.

We're currently on 11.1.1.3 Essbase and Oracle 11 g.

Any help is greatly apprecied.

Just nail it on your WHERE clause in the area WHERE the. I think that you can even stick the entire statement (under the keyword "SELECT") within the area of SELECTION.

Tags: Business Intelligence

Similar Questions

  • SQL loader when error clause

    Hello

    I have this CTL file as below:

    DOWNLOAD THE DATA
    INFILE 'PRODUCT_*.csv '.
    ADD
    IN THE PRODUCT_CONFIG TABLE
    "WHEN <>(1:3) and (1:3) <>' 99" and <>' 00, «,» (1:4),
    FIELDS ENDED BY ',' POSSIBLY FRAMED BY "" "
    TRAILING NULLCOLS
    (
    PARTNUMBER NULLIF PARTNUMBER = BLANKS,
    NULLIF LABEL = BLANKS,
    NULLIF SEQUENCE SEQUENCE = BLANKS,
    NULLIF DISPLAY_FLAG DISPLAY_FLAG = BLANKS,
    BILL_PERIOD NULLIF BILL_PERIOD = BLANKS)

    However, I got this error when I run my file:

    SQL * Loader-350: error of syntax in line 6.
    Expecting "(", found "99".
    "WHEN <>(1:3) and (1:3) <>' 99" and <>' 00, «,» (1:4),


    How can I change my code to solve this error?

    Hello

    After your data, I created a test table and load the data successfully. See if this example helps you

    CREATE TABLE test (
       col1 VARCHAR2 (20),
       col2 VARCHAR2 (30),
       col3 NUMBER,
       col4 NUMBER
    );
    
    load data
    truncate into table test
    when ( col1 !='00') and (col1 !='99')
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (col1 char(20),
    col2 char(30),
    col3 integer external,
    col4 integer external
    );
    
    {code}
    
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    
  • Import data... Wizard creates the file SQL Loader ctl with columns out of order

    4.1.1.19 SQL Developer version. Connected to Oracle XE to test this.

    I'm trying to understand what the problem with the data in my import file when finally, I realize that the Import Wizard of data did not care how I traced the columns at all. The ctl SQL Loader file generated by the Wizard expects that the columns of data in my file to match the order that they appear in the definition of the table and not how they have been mapped in the wizard. Manually edit the ctl file is a workaround. Has anyone else seen elsewhere?

    I see that this is a bug.

  • Reference SQL Loader Bind Variables in the when Clause

    Support for SQL: SQL * Loader: version 8.0.6.3.0 (don't ask, it runs on Oracle EBS 11i...)

    I have a case where my sample data looks like:
    HD00100001002
    SM00100002CHAPS   99999999999                     20120906GBP0000000000001000000000001
    and another file
    HD00100001001
    SM00100002GBP0000000000001000000000001
    Essentially, I need to apply another "IN" clause for each record of SM depends on the ack_type (char 13 on HD recording), either 1 or 2

    I tried setting up the ack_type with a variable binding but find how to reference.

    Example of control file:
    --  $Header: test.ctl
    --
    
    LOAD DATA
    REPLACE
    
    -- Record Type HD : File Header
    INTO TABLE  test_table
    WHEN rec_id_no = 'HD'
    TRAILING NULLCOLS
    (rec_no                 RECNUM,
     hdr_line               CONSTANT 'H',
     rec_id_no              POSITION(1:2)   CHAR,
     file_number            POSITION(3:5)   CHAR,
     sequence_number        POSITION(6:10)  CHAR,
     status                 POSITION(11:12) CHAR,
     ack_type               POSITION(13:13) ":ack_type",
     co_id                  POSITION(14:21) CHAR,
     dept_id                POSITION(22:24) CHAR,
     btch_no                POSITION(25:36) CHAR,
     trans_id               POSITION(37:42) CHAR)
    
    -- Record Type SM : File Summary
    INTO TABLE test_table
    WHEN rec_id_no = 'SM' and :ack_type = '1'
    TRAILING NULLCOLS
    (rec_no                 RECNUM,
     hdr_line               CONSTANT 'L',
     rec_id_no              POSITION(1:2)   CHAR,
     file_number            POSITION(3:5)   CHAR,
     sequence_number        POSITION(6:10)  CHAR,
     ccy_code               POSITION(11:13) CHAR,
     amount                 POSITION(14:26) CHAR,
     number_trans_ok        POSITION(27:40) CHAR)
    The code above does not work, it is said that: ack_type is not recognized. Is there a way to do it, given the former character of the SQL Load version?

    What is the database version 11i is running on? If 11 GR 2, this doc can help you in the use of the features that Dan mentions

    How to use the 9i or 10g features in SQL * Loader for Apps? [423035.1 ID]

    HTH
    Srini

  • Problem in the SQL because of the order by clause

    Hi all
    I am facing a problem in a sql query. I use Oracle 10 g 2.
    Query is given below:
    SELECT t1.ename
            FROM T1, T2
           WHERE T1.EMPNO = 1234
             AND T1.ACCOUNTNO = T2.ACCOUNTNO
             AND T1.SEQ = T2.SEQ
           ORDER BY T2.SEQ
    The query Plan is:
    .----------------------------------------------------------------------------------------------------
    | Id  | Operation                     | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |
     ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT              |                      |     2 |   218 | 11716   (1)| 00:00:41 |
    |*  1 |  TABLE ACCESS BY INDEX ROWID  | T1                   |     1 |    89 |     1   (0)| 00:00:01 |
    |   2 |   NESTED LOOPS                |                      |     2 |   218 | 11716   (1)| 00:00:41 |
    |*  3 |    TABLE ACCESS BY INDEX ROWID| T2                   |     2 |    40 | 11715   (1)| 00:00:41 |
    |   4 |     INDEX FULL SCAN           | PK_T2_SEQ            | 58752 |       |   122   (5)| 00:00:01 |
    |*  5 |    INDEX RANGE SCAN           | FK_ACCOUNTNO         |     3 |       |     0   (0)| 00:00:01 |
     ----------------------------------------------------------------------------------------------------
    Now, I want to reduce the time of this request.

    If I remove order by clause query that the query performance is quite perfect, but with order by clause its take time.

    I already set SORT_AREA_SIZE, but still nothing improves.

    Welcome and thank you for your suggestions.

    Thank you

    Published by: BluShadow on June 23, 2011 07:55
    addition of {noformat}
    {noformat} tags and formatted explain plan to make it readable.  Please see {message:id=9360002} for details on how to post code and data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    Hey, a quick test, try:

    select ename from (
    SELECT t1.ename, T2.SEQ
    FROM T1, T2
    WHERE T1.EMPNO = 1234
    AND T1.ACCOUNTNO = T2.ACCOUNTNO
    AND T1.SEQ = T2.SEQ
    and rownum > 0)
    ORDER BY SEQ
    

    Amiel Davis

  • SQL Loader / WHAT clause / off swich? / bloated log files

    Hello everyone,

    I'm loading data using SQL-Loader very large source files. It all works very well.

    However, now, by using the WHEN clause (in the control file), I would like to only a very small subset of most load data. This also works very well...

    WHEN ARTICLECODE! '000000000000006769' =

    However, the log file becomes fully inflated with messages telling me to each record that does not have the WHEN clause...

    Record 55078: Discarded - failed all WHEN clauses.

    This becomes a problem because it slows down the process and creates large log files that eat upward of my disk space.

    There must be a simple command to allow me to disable the messages of thiese, but although I googled on it, I could not find it.

    Any ideas on this one? I don't know that it's simple.

    Best regards and many thanks,
    Alan Searle

    Try adding the SILENCE = RELEASES key sqlldr command

    Silent means - delete messages during execution (header, comments, errors, discards, partitions)

  • SQL Loader when Clause

    Hello

    I have a requirement to load a file and exclude lines on a column with a value where ID NOT LIKE ' % no data %'

    OPTIONS (SKIP = 3)

    DOWNLOAD THE DATA

    INFILE ' / home/test.csv '

    IN THE test TABLE

    TRUNCATE

    What ID do NOT LIKE ' % no data %'

    ' Surrounded FIELDS TERMINATED BY ',' possibly ' ' '

    TRAILING NULLCOLS

    (ID,

    BEGUN,

    TIME,

    DATE_ADDED SYSDATE

    )

    Some examples of ID:

    Data AVDFGHKL:no

    Data THGEIUJD:no

    The value will always point 10 a go (after the semi colon)

    I tried the following, but not luck

    When (1) = '1') AND (10:2). = 'No '.

    Yes, the outer table can be a better option (the file must be in the server). Depending on your data (i.e. the colon (:)) always comes in 9th place) it will work.)

    [oracle@localhost saubhik]$ cat my_data.txt
    AVDFGHKL:No Data, 09/11/2009
    JFDJFUJK, 09/11/2009
    AGHFJDKK:No Data, 09/11/2009
    TRUTIRUT, 09/11/2009
    [oracle@localhost saubhik]$ 
    
    [oracle@localhost saubhik]$ cat test_emp_ctl.ctl
    LOAD DATA
    INFILE 'my_data.txt'
    INTO TABLE test
    TRUNCATE
    when (9:9) <> ":"
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    (id, start_date DATE(19) "DD-MM-YYYY")
    [oracle@localhost saubhik]$ sqlldr scott/tiger control=test_emp_ctl.ctl
    
    SQL*Loader: Release 11.2.0.1.0 - Production on Tue Jun 2 16:20:22 2015
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 4
    [oracle@localhost saubhik]$ 
    

    Audit:

    SQL> SELECT * FROM test;
    
    ID                             START_DAT
    ------------------------------ ---------
    JFDJFUJK                       09-NOV-09
    TRUTIRUT                       09-NOV-09
    
    SQL> 
    
  • When to use clause I n Sql loader

    Hello

    I had to create three tables as table scripts below
    create table emp(ename varchar2(50), deptno number(5))
    
    insert into emp
    values('ALEX',10);
    
    insert into emp
    values('SMITH',20);
    
    create table emp1(ename varchar2(50), deptno number(5))
    
    create table emp2(ename varchar2(50), deptno number(5))
    My requirement is that I want to insert the deptno 10 values in table and deptno 20 emp1 emp2 table values by
    Using sql * loader.


    My emp.txt testfile contains data below


    ALEX, 10
    SMITH, 20


    my control file code is as below
    LOAD DATA
    
    INFILE 'F:\sqlload\emp.txt'
    BADFILE 'F:\sqlload\empb.bad'
    DISCARDFILE 'F:\sqlload\empd.dsc'
    
    TRUNCATE
    
    INTO TABLE emp1
    WHEN deptno='10'
    FIELDS TERMINATED BY ':'
    (ename,deptno)
    
    INTO TABLE emp2
    WHEN deptno='20'
    FIELDS TERMINATED BY ':'
    (ename,deptno)
    When I execute the control file. only of deptno 10 values are inserted into the table emp1. DEPTNO 20 values are not
    inserted into the table emp2.

    anyone can tell me the what is the error in my control file.


    Kind regards
    Rajesh

    I am pleased to read that it works now.

    The keyword position indicates the sqlldr to start to read again in the first position of the line in the data file.

    Read the block Relative positioning "based the POSITION parameter" in the following documentation:

    http://docs.Oracle.com/CD/B19306_01/server.102/b14215/ldr_control_file.htm#sthref887

    HM

    Published by: hm on 05.02.2013 02:08

  • SQL Loader - ignore the lines with "rejected - all null columns."

    Hello

    Please see the attached log file. Also joined the table creation script, data file and the bad and throw the files after execution.

    Sqlldr customer in the version of Windows-

    SQL * Loader: release 11.2.0.1.0 - Production

    The CTL file has two clauses INTO TABLE due to the nature of the data. The data presented are a subset of data in the real world file. We are only interested in the lines with the word "Index" in the first column.

    The problem we need to do face is, according to paragraph INTO TABLE appears first in the corresponding CTL lines file to the WHEN CLAUSE it would insert and the rest get discarded.

    1. statement of Create table : create table dummy_load (varchar2 (30) name, number, date of effdate);

    2. data file to simulate this issue contains the lines below 10. Save this as name.dat. The intention is to load all of the rows in a CTL file. The actual file would have additional lines before and after these lines that can be discarded.

    H15T1Y Index | 2. 19/01/2016 |

    H15T2Y Index | 2. 19/01/2016 |

    H15T3Y Index | 2. 19/01/2016 |

    H15T5Y Index | 2. 19/01/2016 |

    H15T7Y Index | 2. 19/01/2016 |

    H15T10Y Index | 2. 19/01/2016 |

    CPDR9AAC Index | 2. 15/01/2016 |

    MOODCAVG Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    3. the CTL file - name.ctl

    DOWNLOAD THE DATA

    ADD

    IN THE TABLE dummy_load

    WHEN (09:13) = "Index".

    TRAILING NULLCOLS

    (

    COMPLETED name BY ' | ',.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    IN THE TABLE dummy_load

    WHEN (08:12) = "Index".

    TRAILING NULLCOLS

    (

    COMPLETED name BY ' | ',.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    invoke SQL loader in a file-> beats

    C:\Oracle\product\11.2.0\client\bin\sqlldr USERID = myid/[email protected] CONTROL=C:\temp\t\name.ctl BAD=C:\temp\t\name_bad.dat LOG=C:\temp\t\name_log.dat DISCARD=C:\temp\t\name_disc.dat DATA=C:\temp\t\name.dat

    Once this is run, the following text appears in the log file (excerpt):

    Table DUMMY_LOAD, charged when 09:13 = 0X496e646578 ('Index' character)

    Insert the option in effect for this table: APPEND

    TRAILING NULLCOLS option in effect

    Column Position Len term Encl. Datatype name

    ------------------------------ ---------- ----- ---- ---- ---------------------

    NAME                                FIRST     *   |       CHARACTER

    RATE                                 NEXT     *   |       CHARACTER

    EFFDATE NEXT * |       CHARACTER

    SQL string for the column: ' TO_DATE (: effdate, "MM/DD/YYYY").

    Table DUMMY_LOAD, charged when 08:12 = 0X496e646578 ('Index' character)

    Insert the option in effect for this table: APPEND

    TRAILING NULLCOLS option in effect

    Column Position Len term Encl. Datatype name

    ------------------------------ ---------- ----- ---- ---- ---------------------

    NAME                                 NEXT     *   |       CHARACTER

    RATE                                 NEXT     *   |       CHARACTER

    EFFDATE NEXT * |       CHARACTER

    SQL string for the column: ' TO_DATE (: effdate, "MM/DD/YYYY").

    Record 1: Ignored - all null columns.

    Sheet 2: Cast - all null columns.

    Record 3: Ignored - all null columns.

    Record 4: Ignored - all null columns.

    Sheet 5: Cast - all null columns.

    Sheet 7: Discarded - failed all WHEN clauses.

    Sheet 8: Discarded - failed all WHEN clauses.

    File 9: Discarded - failed all WHEN clauses.

    Case 10: Discarded - failed all WHEN clauses.

    Table DUMMY_LOAD:

    1 row loaded successfully.

    0 rows not loaded due to data errors.

    9 lines not loading because all WHEN clauses were failed.

    0 rows not populated because all fields are null.

    Table DUMMY_LOAD:

    0 rows successfully loaded.

    0 rows not loaded due to data errors.

    5 rows not loading because all WHEN clauses were failed.

    5 rows not populated because all fields are null.


    The bad file is empty. The discard file has the following

    H15T1Y Index | 2. 19/01/2016 |

    H15T2Y Index | 2. 19/01/2016 |

    H15T3Y Index | 2. 19/01/2016 |

    H15T5Y Index | 2. 19/01/2016 |

    H15T7Y Index | 2. 19/01/2016 |

    CPDR9AAC Index | 2. 15/01/2016 |

    MOODCAVG Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |


    Based on the understanding of the instructions in the CTL file, ideally the first 6 rows will have been inserted into the table. Instead the table comes from the line 6' th.

    NAMERATEEFFDATE
    H15T10Y Index2January 19, 2016



    If the INTO TABLE clauses were put in the CTL file, then the first 5 rows are inserted and the rest are in the discard file. The line 6' th would have a ""rejected - all columns null. "in the log file. "


    Could someone please take a look and advise? My apologies that the files cannot be attached.

    Unless you tell it otherwise, SQL * Loader assumes that each later in the table and what clause after the first back in the position where the previous left off.  If you want to start at the beginning of the line every time, then you need to reset the position using position (1) with the first column, as shown below.  Position on the first using is optional.

    DOWNLOAD THE DATA

    ADD

    IN THE TABLE dummy_load

    WHEN (09:13) = "Index".

    TRAILING NULLCOLS

    (

    name POSITION (1) TERMINATED BY ' | '.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    IN THE TABLE dummy_load

    WHEN (08:12) = "Index".

    TRAILING NULLCOLS

    (

    name POSITION (1) TERMINATED BY ' | '.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

  • SQL loader question

    Hi people,

    Please find the table with the records below

    CREATE TABLE EMPLOYEE_LOAD (ID NUMBER, NAME VARCHAR2 (100), UNIVERSITY_NAME VARCHAR2 (100));

    File to load: employee.txt

    ID | NAME | UNIVERSITY_NAME

    1. JAMES | UNIVERSITY OF MIT

    2. LISA | UNIVERSITY OF CAMBRIDGE

    3. MINDY | "THIS UNIVERSITY

    4. ' ALLEN J |' IT UNIVERSITY

    5. ' MIKE'ALLEN | "THIS UNIVERSITY

    I've written SQL Loader control as file below

    OPTIONS(SKIP=1,DIRECT=TRUE)

    DOWNLOAD THE DATA

    INFILE ' mnt/employee.txt.

    BADFILE "mnt/employee.bad.

    DISCARDFILE ' mnt/employee.dsc.

    ADD THE EMPLOYEE_LOAD TABLE

    FIELDS TERMINATED BY ' | '. SURROUNDED OF POSSIBLY ' ' ' TRAILING NULLCOLS

    (

    ID,

    NAME,

    UNIVERSITY_NAME

    )

    sqlldr userid = < username > @database/password control=/mnt/employee.ctl log=/mnt/employee.log

    Only 2 first recordings are loading (excluding the header) and face below errors

    (1) no terminator found after CLOSE and CLOSED field

    (2) second string for the attachment does not exist

    These 3 recordings are in the wrong files and how do I force sql loader to load subfolders too?

    3. MINDY | "THIS UNIVERSITY

    4. ' ALLEN J |' IT UNIVERSITY

    5. ' MIKE'ALLEN | "THIS UNIVERSITY

    Try to remove the ENCLOSED BY ' ' ' clause.  It is not true, according to your sample data.

    These quotes seem to be interspersed randomly.

  • On the use of SQL * loader program pl/sql command

    Is it possible to develop a PL/SQL program that calls SQL * Loader (sqlldr userid =...) command?

    We want to package a process that loads data from a text file into a table, and we research it is possible to use SQL * Loader to the data loading process.

    You can launch sqlldr like all other orders of operation. There are several methods of cooking OS command, as

    1. external procedure PL/SQL: CHMOD FROM A PLSQL?

    Johan's blog: how to call PL/SQL kernel32.dll.

    2 Java Stored Procedure: Blog of Johan: using JAVA in PL/SQL - PART - I list files with timestamp , Blog of Johan: using JAVA in PL/SQL - PART - II operating system information obtaining

    3. external PREPROCESSOR Table function: no response on java not call windows in oracle command

    Johan's blog: list uses of disk operating system with external feature of the Oracle PREPROCESSOR Table

    Johan's blog: operating system from the list of files with external feature of the Oracle PREPROCESSOR Table

    4. using DBMS_SCHEDULER,job_type => 'executable' and job_action  => '/bin/sh' (may be)

  • Name of dynamic INFILE SQL loader

    Hi all

    I use oracle 10g on windows server.

    I have a log on a remote server. each line in the log file is as below

    LogIN Mar 02/09/2014 10:10:48 ss18 N419FS40 1

    I create a table for that as below;

    Create table free_pc (log_in varchar2(10),log_day varchar2(10),log_date date,log_time date,log_user varchar2(30),log_Lab varchar2(30),log_pc varchar2(30), log_status char(1));
    

    I have two problems;

    1 N419FS40, the N419 is the name of a student in the lab, while FS40 is the name of the computer in this laboratory. I want only the first four characters to be inserted into the column of Log_lab and the rest of characters iin Log_pc column. my control file is less than

    DOWNLOAD THE DATA

    INFILE '\\remote_location\login02_09_14.txt '.

    ADD

    IN THE TABLE free_pc

    FIELDS FINISHED WITH A WHITE SPACE

    (log_in,

    log_day,

    log_date DATE "DD/MM/YYYY",

    log_time DATE "HH24 MI SS."

    LOG_USER,

    log_Lab,

    log_PC,

    log_status

    )

    How to do this?

    2. the log file is generated on the server, every day with a different name, he cancatenate the current date with Word LOGIN, for example login02_09_14.txt, login03_09_14.txt and login04_09_14 etc. in my INFILE tag, how can I put the name, so that it automatically take the name of the remote location?

    Thank you.

    Kind regards.

    1. you can use the SUBSTR function to separate the two values.  You put the fields in the control file in the same order in the data file, with all the columns that are formulated from data in other areas at the end.

    2. There are different ways to do this.  The file name can be in the control file or the SQL * Loader command line.  You can create either using SQL/SQL * Plus or operating system commands.  I tend to prefer change just the line of SQL * Loader command line, instead of the entire control file.  I prefer to do this in a SQL file instead of a file breaks Windows or * ix shell script or something, so that it is independent of the operating system.

    In addition, it is best to store all of your day, date and time in a column, then you can use to_char to display it as you want, in a column, or two or three.

    Please see the example below, in which I have shown above.

    Scott@ORCL >-data file you provided with the name changed to include today's date:

    Scott@ORCL > HOST TYPE 'c:\remote_location\login27_04_15.txt '.

    Opening on Tuesday, September 2, 2014 ss18 N419FS40 1 10:10:48

    Scott@ORCL >-control file with no infile, fields in the order of the data file, using fill for the unused columns,.

    Scott@ORCL >-with forumulated columns, using boundfiller for filling necessary for columns columns drawn up:

    Scott@ORCL > test.ctl TYPE of HOST

    DOWNLOAD THE DATA

    ADD

    IN THE TABLE free_pc

    FIELDS FINISHED WITH A WHITE SPACE

    TRAILING NULLCOLS

    (log_in,

    log_day FILLING,

    log_date BOUNDFILLER,

    log_time BOUNDFILLER,

    LOG_USER,

    log_Lab ' SUBSTR (: log_lab, 1, 4). "

    log_status,

    log_date_time ' TO_DATE (: log_date |: log_time, "MM/DD / YYYYHH24:MI:SS'"). "

    log_PC ' SUBSTR (: log_lab, 5) ')

    Scott@ORCL >-sql script which now enables to get the data and it concatenates the file name with the path of the directory

    Scott@ORCL >- and loads the data running SQL * Loader of SQL * Plus, using the HOST command:

    Scott@ORCL > test.sql TYPE of HOST

    COLUMN data_file new_value data_file

    SELECT 'c:\remote_location\login ' | TO_CHAR (SYSDATE, 'DD_MM_YY'). ".txt" AS data_file FROM DUAL

    /

    HOST SQLLDR scott/tiger CONTROL = test.ctl DATA = '& data_file' LOG = test.log

    CLEAR COLUMN

    Scott@ORCL >-table which includes the date and time in a column, for the day of the week can be extracted:

    Scott@ORCL > create table free_pc

    2 (log_in varchar2 (10))

    3, date log_date_time

    4, log_user varchar2 (30)

    5, log_Lab varchar2 (30)

    6, log_pc varchar2 (30)

    7, log_status char (1))

    8.

    Table created.

    Scott@ORCL >-load data file sql running running SQL * Loader using the control file:

    Scott@ORCL > test.sql START

    Scott@ORCL > data_file new_value data_file COLUMN

    Scott@ORCL > SELECT 'c:\remote_location\login ' | TO_CHAR (SYSDATE, 'DD_MM_YY'). ".txt" AS data_file FROM DUAL

    2.

    DATA_FILE

    ------------------------------------

    c:\remote_location\login27_04_15.txt

    1 selected line.

    Scott@ORCL > HOST SQLLDR scott/tiger CONTROL = test.ctl DATA = '& data_file' LOG = test.log

    SQL * Loader: release 11.2.0.1.0 - Production on my Apr 27 12:00:53 2015

    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

    Commit the point reached - the number of logical records 1

    Scott@ORCL > CLEAR COLUMN

    Scott@ORCL >-results with Date_Time field displayed in the form of day, date and time:

    Scott@ORCL > log_in COLUMN FORMAT A6

    Scott@ORCL > log_day COLUMN FORMAT A7

    Scott@ORCL > log_user COLUMN FORMAT A8

    Scott@ORCL > log_lab COLUMN FORMAT A8

    Scott@ORCL > log_pc COLUMN FORMAT A6

    Scott@ORCL > log_status FORMAT A10 COLUMN

    Scott@ORCL > SELECT log_in,.

    2 TO_CHAR (log_date_time, ' HH24:MI:SS Dy DD-Mon-YYYY ') ' DAY DATE TIME. "

    3 log_user, log_lab, log_pc, log_status

    4 FROM free_pc

    5.

    LOG_IN DAY DATE TIME LOG_USER LOG_LAB LOG_PC LOG_STATUS

    ------ ------------------------------------------ -------- -------- ------ ----------

    LogIN Mar 02 - Sep - 2014 ss18 N419 FS40 1 10:10:48

    1 selected line.

  • SQL Loader

    Hello

    I need to load the data into the database using sql loader.

    1. is it possible to change the case of text before you load the data into the table. For example. conversion of names to lowercase before inserting into the database.

    2. why or condition is not in the 'when' control file clause? are there any alternatives that I can use to satisfy conditions similar to the place of use or condition?

    Thanks in advance.

    You can use two condition for your condition... As below...

    WHEN column_2 = '01'

    IN TABLE

    WHEN column_2 = '02'

    IN TABLE

    If you have files on server side, you can use the external table to load the conditional data.

    Thank you

    Ann

  • How to remove the Order By clause

    How can I get rid of the Order By clause in the underlying SQL query? I created a simple hierarchy, but when I use the hierarchy in the analysis and then come down, the results show multiple occurrences of each child. For some reason, I was able to reduce the number of occurrences of each child by adding a saved filter.

    I was expecting this:

    Expected.jpg

    Instead, I got this:

    Actual.jpg

    The generated physical query looks like this:

    SET VARIABLE QUERY_SRC_CD = "report"; SELECT s_0, s_1, s_2, s_3, s_4 s_5, (FROM s_6)

    SELECT

    s_0 0,.

    CAST (NULL AS VARCHAR s_1 (1)).

    "Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.

    'All the colleges' s_3,.

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").

    MOUNT s_5 (NULL AS DOUBLE),

    "Registration - College". "" Counties of schooling. "" Full-time student "s_6

    "REGISTRATION - College".

    UNION ALL

    SELECT

    1 s_0

    "Registration - College". «Dimensions of the inscription '.» "" Name of College "s_1,.

    "Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.

    'All the colleges' s_3,.

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_5 College ').

    "Registration - College". "" Counties of schooling. "" Full-time student "s_6

    "REGISTRATION - College".

    WHERE

    ("Registration - College". «Dimensions of the inscription '.» ("' Exercise ' IN ('201213')) AND (IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". (("' Colleges ') (1))

    ) djm ORDER OF 1, 3 ASC NULLS LAST, 4 ASC NULLS FIRST, 5 ASC NULLS FIRST, 2 ASC NULLS FIRST, NULLS FIRST CSA 6

    EXTRACT FIRST 10000000 LINES ONLY

    HI mbengue,.

    Check the report you are running any column presentation sorted in the user interface (in which case the order by clause will creep into generated sqls Physics). Also, I think that its worth it to check the settings of the hierarchy you have configured and if the installation program for the calculation of the measured column (number of students in this case), has been done correctly.

    Kind regards

    Arko

  • Shift columns in SQL Loader

    Hi all

    I have a flat file with 5 columns in it.

    My requirement is to download records using SQL loader only when all the 5 columns are present in the flat file.

    Please suggest if its possible.

    Hello

    Use a WHEN clause in the control file.

    WHEN (col1 IS NOT NULL AND IS NOT NULL col2 AND col3 IS NOT NULL AND col4 IS NOT NULL AND IS NOT NULL col5)

Maybe you are looking for