Sql loader using sql statement

Hi All ,
May i know any way used sql loader refer sql statement e.g "select a from test"
import data into other table ?
if you have any sample or link , please let me know , thanks a lot

If you are using the database steps, the answer is yes. I've done it by creating a data source that uses the Microsoft Text Driver in the ODBC administrator. The Open Database step is then configured like any other ODBC database. In the .csv file, I have the first line define the column names (i.e. column1, column2) and the SQL statement I use is "SELECT * FROM junk.txt". I haven't tried anything with a WHERE clause but that should work as well.

Similar Messages

  • Calling SQL Loader from SQL Plus

    Hi everyone,
    I currently use both SQL Loader and SQL Plus to load data and to then carry out certain DML tasks and to reinstate indexes. That all works fine but of course I need to be present to start and to monitor the various scripts.
    What I would really like to do is to be able to incorporate the calls to SQL-Loader into my SQL-Plus scripts and am wondering if this is possible.
    At the moment I run some parts of the load in 'batch' (i.e. command line calls to SQL-Loader and to SQL-Plus) but this won't work for the whole load because the batch calls (from Windows) are not able to wait for particular processes to finish before they start the next. This works OK for the SQL-Loader scripts (because they can run in parallel) but will not work for the whole load because the load needs to be finished before the further processing starts.
    Or maybe there is a way (Windows .BAT files?) to set up batch processes which are intelligent enough to wait for one action to finish before starting the next action.
    Any thoughts or any links to HOWTOs on this would be a great help.
    Regards and thanks,
    Alan Searle

    Hi Alan,
    In SQL*Plus you have the HOST command.
    I would go for the .bat solution using [START /WAIT|http://www.computerhope.com/starthlp.htm]
    Regards
    Peter

  • Tuning sql automatic using SQL Tuning Advisor Tool

    I need to work on Automatic sql tuning..
    Please give suggestion for the below
    1) I have installed oracle11g client version. confirm this is okey for my project. because i heard we should have oracle enterprise edition for this.
    2) User with only sys privelage can work on this automatic sql tuning using sql tuning advisior tool.
    Please clarify above suggestions.
    ALso suggest me best way to proceed further
    S

    Sunny kichloo wrote:
    This docs will help
    http://www.oracle-base.com/articles/10g/automatic-sql-tuning-10g.php
    http://www.oracle-base.com/articles/11g/automatic-sql-tuning-11gr1.php
    Thanks for your link. i already seen this link.
    Could u pls answer my question on above with " Yes" or "No"
    Kindly reply
    S

  • SQL LOADER USING EXTRNAL TABLE

    I have .csv file having around 70k records
    in which fields are delimited by tab and
    enclosed in double quotes but double quotes may be part of data.
    and records are delimited by newline.
    After creating external table when I issue SELECT statment
    select count(*) from proTxt ;
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04020: found record longer than buffer size supported, 524288, in C:\Program Files\Apache Software Foundation\Tomcat
    5.5\webapps\tmTest\upload\product\Data\output09_1.txt
    ORA-06512: at "SYS.ORACLE_LOADER", line 19
    Following is the create table statement:
    CREATE TABLE proTxt (PRO_CODE VARCHAR2(30),
    PRO_DESC VARCHAR2(500),
    PUR_PRICE VARCHAR2(20),
    SALE_PRICE VARCHAR2(20)
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY DAT_DIR
    ACCESS PARAMETERS
    records delimited by NEWLINE SKIP 1
    badfile BAD_DIR:'proTxt%a_%p.bad'
    logfile LOG_DIR:'proTxt%a_%p.log'
    fields terminated by X'9' OPTIONALLY ENCLOSED BY '"' AND '"'
    missing field values are null
    ( PRO_CODE,
    PRO_DESC,
    PUR_PRICE,
    SALE_PRICE
    LOCATION ('output09_1.txt')
    PARALLEL 4
    REJECT LIMIT UNLIMITED;
    record size is not large.
    Log file :
    LOG file opened at 12/05/12 20:25:40
    KUP-04020: found record longer than buffer size supported, 524288, in C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\tmTest\upload\product\Data\output09_1.txt
    KUP-04053: record number 2
    data file
    PRO_CODE     PRO_DESC     PUR_PRICE     SALE_PRICE
    "0000336658"     "BEARING"     "Rs.0.00"     "Rs.0.00"
    "0000790028"     "SEAL"     "Rs.76.00"     "Rs.90.00"
    "0000790118"     "SPRING"     "Rs.24.00"     "Rs.28.00"
    "0000792284"     "F.BRK.CAL.W/O PA"     "Rs.2,627.00"     "Rs.3,100.00"
    "0000792285"     "F.BRK.CAL.W/O PA"     "Rs.2,627.00"     "Rs.3,100.00"
    "0005896322"     "PISTON, RING"     "Rs.5,000.00"     "Rs.5,900.00"
    "0005896323"     "PISTONS, RINGS AND P"     "Rs.17,755.00"     "Rs.20,951.00"
    "0005896559"     "PISTON, RINGS AND PI"     "Rs.5,000.00"     "Rs.5,900.00"

    Hi,
    when i used
    records delimited by *'\r'*
    then 4226 record written to table
    but enclosed charcter double quotes["] were also written and
    there is some space between charcters
    " 0 0 0 0 3 3 6 6 5 8 " " B E A R I N G " " R s . 0 . 0 0 " " R s . 0 . 0 0 "
    " 0 0 0 0 8 5 6 7 0 7 " " P L U G " " R s . 0 . 0 0 " " R s . 0 . 0 0 "
    Definitely this is "External Table with Flatfile Moved Across Platforms" issue.
    when I opened .csv file in excel and saved as tab delimited it works fine.
    But I do not know plateform of data file.
    How to know the CHARACTERSET of data file
    Log file
    Field Definitions for table PROTXT
    Record format DELIMITED, delimited by
    Data in file has same endianness as the platform
    Rows with all null fields are accepted
    Fields in Data Source:
    PRO_CODE CHAR (255)
    Terminated by "9"
    Enclosed by """ and """
    Trim whitespace same as SQL Loader
    PRO_DESC CHAR (255)
    Terminated by "9"
    Enclosed by """ and """
    Trim whitespace same as SQL Loader
    PUR_PRICE CHAR (255)
    Terminated by "9"
    Enclosed by """ and """
    Trim whitespace same as SQL Loader
    SALE_PRICE CHAR (255)
    Terminated by "9"
    Enclosed by """ and """
    Trim whitespace same as SQL Loader

  • Data Loading using SQL* Loader giving errors..

    While loading the data using SQL* Loader, I came across the following errors:
    - SQL*Loader-00604 Error occurred on an attempt to commit
    - ORA-01041 internal error. hostdef extension doesn't exist
    My Control and Data files have proper Carriage Returns i.e. the last line of both the files is blank.
    So, if somebody know about this, plz help me.
    Thanx

    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

  • Need faster data loading (using sql-loader)

    i am trying to load approx. 230 million records (around 60-bytes per record) from a flat file into a single table. i have tried sql-loader (conventional load) and i'm seeing performance degrade as the file is being processed. i am avoiding direct path sql-loading because i need to maintain uniqueness using my primary key index during the load. so the degradation of the load performance doesn't shock me. the source data file contains duplicate records and may contain records that are duplicates of those that are already in the table (i am appending during sql-loader).
    my other option is to unload the entire table to a flat file, concatenate the new file onto it, run it through a unique sort, and then direct-path load it.
    has anyone had a similar experience? any cool solutions available that are quick?
    thanks,
    jeff

    It would be faster to suck into a Oracle table, call it a temporary table and then make a final move into the final table.
    This way you could direct load into an oracle table then you could
    INSERT /*+ APPEND */ INTO Final_Table
        SELECT DISTINCT *
        FROM   Temp_Table
        ORDER BY ID;This would do a 'direct load' type move from your temp teable to the final table, which automatically merging the duplicate records;
    So
    1) Direct Load from SQL*Loader into temp table.
    2) Place index (non-unique) on temp table column ID.
    3) Direct load INSERT into the final table.
    Step 2 may make this process faster or slower, only testing will tell.
    Good Luck,
    Eric Kamradt

  • Sql loader using position and functions

    Hi all, i need help loading some data in my table using sql loader. consider the following
    CREATE TABLE er
    a1 NUMBER,
    a2 number,
    a3 VARCHAR2(100),
    a4 VARCHAR2(100),
    a5 VARCHAR2(100),
    a6  VARCHAR2(100),
    a7  VARCHAR2(100),
    a8  VARCHAR2(100)
    OPTIONS (BINDSIZE=20548000, READSIZE=20548000, STREAMSIZE=20548000, DATE_CACHE=25000,  SKIP=0)
    LOAD DATA
    INTO TABLE er
    APPEND    
    TRAILING NULLCOLS
      a1            POSITION(0001:0021)               ,
      a2            POSITION(0022:0042)       "DECODE(SUBSTR(:a2,1,3),'***',NULL,:a2)"      ,
      a3            POSITION(0043:0053)       ,
      a4            POSITION(0054:0064)          ,
      a5            POSITION(0065:0075)           ,
      a6            POSITION(0076:0086)       ,
      a7            POSITION(0087:0093)      "DECODE(SUBSTR(:a7,1,3),'***',NULL,:a7)"  
    BEGIN
                     0.00 ******************** X          X          X          *X          ****
    END;if you look at the data, some fields have a lot of * and some has af few such as ****. i want to load this data into a table and when a field contain all * as a value, i want to set it to null. if a field contain a * and alphanumeric then that value should be load as it is.
    in the example above, ******************** should be set to null and **** should also be set to null. notice that there is a field with X. since this field contain alpha numeric, it should be loaded into the table as is.  the only time field should be set to null is when the value contain all .
    somebody in this forum suggest using decode but it looks like it is not working and i get error when it reads second field and try to insert into a2 number column.
    is there any way to use regular expression to find out if a field contain all *. also i want to trim each field since they might contain leading spaces.
    can some one help with this using the sqlloader ctl and data above?

    You can include regular expression in you SQL*Loader control file.
    An example can be found here:
    http://www.morganslibrary.org/reference/sqlloader.html
    Demos 7 and 8 using the UPPER and DECODE functions to illustrate how to do it.

  • Calling SQL Loader using HOST command from Developer Forms 4.5

    I want to execute a set of code from D2K Forms 4.5 which has interfface with Client - OS ( In my case Windows NT/XP). I want to execute SQL Loader from Forms using Host Command and then after completion of that process, I want to do next transcations ( depending upond success of HOST/SQL Loader).
    How to achive this?
    I tried writing code like this ...
    l_vc_command := 'sqlldr73'
                        ||' USERID='||l_vc_username||'/'||l_vc_password||'@'||l_vc_connect_string
                        ||' CONTROL='||l_vc_filepath||'Upload.ctl'
                        ||' DATA='||LTRIM(RTRIM(l_vc_fileloc))
                        ||' LOG='||l_vc_filepath|| l_vc_log_file || '_' || l_dt_sysdate_str ||'.log'                    
                        ||' BAD='||l_vc_filepath|| l_vc_bad_file || '_' || l_dt_sysdate_str ||'.bad'
                        ||' DISCARD='||l_vc_filepath|| l_vc_discard_file || '_' || l_dt_sysdate_str ||'.dsc';
    HOST(l_vc_command,NO_PROMPT);
    After this command i want to do some other code execution. so even if it fails or success, next code is executed. How to control this?
    Please help..
    Regards,
    Milind

    Forms6i running on W2000, Rdbms 8.1.7
    in Forms I added a button TEST,
    Trigger when-button-pressed : host('test.bat') ;
    in directory .......\frm I added file test.bat :
    REM ===============
    cd /d C:\........\ldr
    pause
    sqlldr parfile=test.par
    pause
    type test.log
    pause
    exit
    REM ================
    now, pressing TEST button opens DOS window, telling me what's going on, running sqlldr, finally going back to forms
    Are you using NO_PROMPT or NO_SCREEN option of HOST command ?
    Had a look at Forms 4.5 manuals, there is no mentioning of (a)synchronously operation in connection with HOST command.

  • Sql*loader using JSP

    wht is the way of using sqlldr in JSP script to load data Oracle DB from a csv file.
    i know how we do sqlldr in cmd.
    can we provide the sqlldr command to system by using jsp if yes how?

    SQL*Loader is a command-line utility. In theory, since Java can call out to the operating system, you could invoke SQL*Loader on the application server to load data into Oracle. It would probably be more appropriate, though, to copy the CSV to the database server and make use of an external table in the database to do the load.
    Justin

  • Export table format SQL loader using spool

    Hi
    In enviroment I only access for to do SELECT , then I want to export some tables using SELECT using spool of data
    But I wanted export in format Sql Loader for to import other environment
    Is possible to do It ?

    Depends where the NULL is.
    SQL> SELECT * FROM t ORDER BY 1;
            ID DESCR      DT
             1 One
             2            30-MAY-2007
             4 Four       30-MAY-2007
               Three      30-MAY-2007
    SQL> SELECT id||',"'||descr||'",'||TO_CHAR(dt,'dd-mon-yyyy') output
      2  FROM t
      3  ORDER BY 1;
    OUTPUT
    ,"Three",30-may-2007
    1,"One",
    2,"",30-may-2007
    4,"Four",30-may-2007John

  • Data Loading using Sql Loader

    Hi
    I have the following column in my data file
    C1,C2,C3,C4,C5,C6
    the columns in my table are
    A1,A2,A5,A6
    the datatype for the columns are varchar.
    the value to be inserted is as follow
    C1=A1
    C2=A2
    C5=A5
    C6=A6
    MY ctl file is as follows
    OPTIONS(SKIP=1, ERRORS=99, ROWS=100)
    LOAD DATA
    APPEND
    INTO TABLE xxx
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    A1 "C1",
    A2 "C2",
    A3 FILLER,
    A4 FILLER,
    A5 "C5",
    A6 "C6"
    I got the below error
    SQL*Loader-350: Syntax error at line
    Expecting "," or ")", found "FILLER".
    Requirement is there is not need of the column C3,C4...
    (Note i cannot delete the column )
    Pls do help me out.
    Regards
    Yram

    Something like the below probably could help you if you don’t want to use the keyword FILLER in the CTL file, take a look –
    The idea is to use the FULL text to load and then extract the columns from the position required within the string –
    Table –
    SQL> desc test
    Name                                      Null?    Type
    COL1                                               VARCHAR2(10)
    COL2                                               VARCHAR2(10)
    COL3                                               VARCHAR2(10)
    COL4                                               VARCHAR2(10)
    COL5                                               VARCHAR2(10)
    COL6                                               VARCHAR2(10)
    COL7                                               VARCHAR2(10)
    COL8                                               VARCHAR2(10)
    COL9                                               VARCHAR2(10)
    COL10                                              VARCHAR2(10)
    Data File
    Col1x,Col2x,Col3x,col4x,col5x,col6x,col7x,col8x,col9x,col10x
    Mapping
    Col1                :  Collx
    Col3                :  Col3x
    Col5                :  Col8x
    Col8                :  Col10x
    *** Rest all the columns not mapped to the Data file
    The Control File
    Load Data
    INFILE '/temp/Shailender/test.dat'
    Into TABLE Test
    APPEND
    TRAILING NULLCOLS
      Col1   position(1:61)   "Substr(:Col1, 1, INSTR(:col1,',',1)-1)"
    ,Col3   position(1:61)   "Substr(:Col3, INSTR(:col3,',',1,2)+1, ( INSTR(:col3,',',1,3)-INSTR(:col3,',',1,2)-1 ))"
    ,Col5   position(1:61)   "Substr(:Col5, INSTR(:col5,',',1,7)+1, ( INSTR(:col3,',',1,8)-INSTR(:col3,',',1,7)-1 ))"
    ,Col8   position(1:61)   "Substr(:Col8, INSTR(:col8,',',-1)+1)"
    SQL> select * from test
      2  /
    COL1       COL2       COL3       COL4       COL5       COL6       COL7
    COL8       COL9       COL10
    Col1x                 Col3x                 col8x
    col10x
    Shailender Mehta

  • Executing SQL Loader ----- Using Java & C!!!!!!!!!!!!!

    Hello,
    We r confirmed that to execute SQL Loader,
    One need to write an External Routine.
    So First Step itself need to create a
    'C' file which executes our sql Loader or
    Using Java.
    How Can I execute the SQL Loader (.exe)
    using Java?
    How can I proceed? Waiting ASAP. Thankyou
    Abhay
    null

    I have a nice piece of Java code that allows you to execute OS commands from within a PL/SQL block in Oracle. If you need the code send me an email. I know it works in Unix and it should work on most platforms.

  • SQL Loader: using your own function

    Hi,
    Is it possible to include your own function in sql*loader? Would this be a correct syntax?
    LOAD DATA
    APPEND
    INTO TABLE MY_TABLE
    IDE "my_seq.nextval"
    CLIENT_NBR POSITION (1:10)          CHAR     
    CLIENT_TYP POSITION (11:12)     "MY_PACKAGE.MY_FUNCTION(:CLIENT_TYP)"
    )So the value of the data ( position 11:12) needs te be processed first by the function. The result of the function needs to be stored in the CLIENT_TYP column.
    Thank you
    Message was edited by:
    Ratjeuh

    still yes/yes after the edit?Yes :)

  • Dynamic SQL without using SQL

    I have a variable that contains a formula, eg.
    V_FORMULA varchar2(200) := '5 * 50 + 200';
    I want to assign the result of the formula into another variable, without using a DB call with SQL.
    eg.
    V_RESULT number;
    V_RESULT := DBMS_surprise_package(V_FORMULA);
    I want V_RESULT to be 450 after the statement is executed.
    Is that possible?? Is there such a package in PLSQL?
    I think the Forms NAME_IN package did something similar.

    970779 wrote:
    I guess I'll just have to rewrite it using execute immediate with bind variables to stop the shared pool getting filled up with thousands of these statements, since none of you have a non-db solution.Write your own if the expressions are simple enough...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    l_formula varchar2(200) := '5 * 50 + 200';
      3    l_result  number := 0;
      4    tok       varchar2(100);
      5    op        varchar2(100);
      6    function get_token(str in out varchar2) return varchar2 is
      7    begin
      8      tok := trim(regexp_substr(str,'^[0-9]+|[^0-9]+'));
      9      str := trim(regexp_replace(str,'^([0-9]+|[^0-9]+)'));
    10      return tok;
    11    end;
    12  begin
    13    loop
    14      tok := get_token(l_formula);
    15      exit when tok is null;
    16      if tok in ('*','+','-','/') then
    17        op := tok;
    18      else
    19        case op when '*' then l_result := l_result * to_number(tok);
    20                when '+' then l_result := l_result + to_number(tok);
    21                when '-' then l_result := l_result - to_number(tok);
    22                when '/' then l_result := l_result / to_number(tok);
    23        else l_result := to_number(tok);
    24        end case;
    25      end if;
    26    end loop;
    27    dbms_output.put_line(l_result);
    28* end;
    SQL> /
    450
    PL/SQL procedure successfully completed.:D

  • SQL Loader error: SQL*Loader-926. Please help

    Hi,
    While loading some files to my database table, I am getting the following error. I am using 'Truncate' option while loading the file:
    Error:
    ====
    SQL*Loader-926: OCI error while executing delete/truncate (due to REPLACE/TRUNCATE keyword) for table LOS_STAGE_DS4
    ORA-01426: numeric overflow
    Here's the loader properties(excerpts from load log)
    ================================
    SQL*Loader: Release 11.1.0.6.0 - Production on Fri Nov 26 04:54:18 2010
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    Control File: d:\Prod\rent_Load\Bin\rent_Load.ctl
    Data File: d:\Prod\rent_Load\Data\rent.704
    Bad File: d:\Prod\rent_Load\Bad\rent.704
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 1000000000
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    Table LS_STAGE, loaded from every logical record.
    Insert option in effect for this table: TRUNCATE
    Column Name Position Len Term Encl Datatype
    Could someone please help and advise what is the root cause of this error?
    Thanks,

    The root cause is in the error ora-1426, which you can look up in the online error documentation at http://tahiti.oracle.com . No one knows every error message by heart. This means it is expected you look up the error prior to posting, and you don't expect any volunteer in this forum to look up the error on your behalf.
    Also this is a typical candidate for being a known problem, and known problems can be found on My Oracle Support.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for