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

Similar Messages

  • 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

  • Date formats for SQL statements used by recordset object

    Hi,
    Date formatting appears to be quite problematic for Business One.  I did a forum search for date issues and I don't think I saw any of them with an "answered" status.  I have an issue with formatting a date for the creation of an SQL statement that the DI sends to SQL Server 2005.  I need to format a date so that the localization parameters don't matter for either the client machine or SQL Server's machine.  We don't have a problem as long as our machines are localized as USA.
    I have PL 22 and I have a form - ours - where I use the Today() function to fill a date field.  So this is a date that is not entered by the user.  The result of this function is consistent with the localization parameters on my machine.  We have two other date fields on the form where the user must type in the date. 
    As a test, I changed my machine to the UK parameters.  I then set up the language parameters of Business One for English(United Kingdom).  I changed the date format specifications in Business One so that its format is dd/mm/yy.  I then brought up the form and the field that is formatted by the above function arrived in the form's field as dd/mm/yy.  I then typed in the two other dates in the same format and added the record to the database.  The form's table is user-defined. 
    I dismissed the form then brought it back up loaded with the new record.  The date that was entered by the function appeared in USA format (mm/dd/yy).  The dates that were typed in appeared in the Business One format (dd/mm/yy).  This of course is not consistent.
    When I looked at what got into the database, the formats were the opposite.  Weird!  To make matters really confusing, I run an SQL statement within SQL Server Mgt Studio, and use the WHERE clause to filter on the date that was based on the function.  It didn’t matter what format I used for the WHERE clause, the record came up.  Does anyone have any idea about how I can ensure that I always use the correct date format for SQL statements passed by Business One to SQL Server regardless of where in the world the application is being run?
    Thanks,
    Mike

    Ian,
    Here's what I'm concerned about:  I’m using the date in a “WHERE” clause.
    Assume the date is Aug 3, 2007.
    "SELECT * FROM Table WHERE StartDate > ‘8/3/2007’"
    OR
    "SELECT * FROM Table WHERE StartDate > ‘3/8/2007’"
    If the client machine is set up as USA, the today function will provide the date as formatted in the first query.  If the database server is setup as let’s say the UK, I believe that SQL Server query parser will interpret the date as Mar 8, 2007.
    If the client machine is set up as UK, the today function will provide the date as formatted in the second query.  If the database server is setup as let’s say USA, I believe that SQL Server query parser will also interpret the date as Mar 8, 2007.
    In both cases it would be wrong.
    I know I could use the DATEPART function to get the three parts and this will make the code indifferent to the localization specs of the client machine.  I need to then be able to concatenate those date parts for the “WHERE” clause so that the localization specifications of the database server don’t matter.
    Thanks,
    Mike

  • How to set default directory for SQL LOADER

    hi all,
    i wanted to know how can we setup a default directory for SQL LOADER if at all we can. i connot place my control and data files in local system and use them at command prompt. rather i wanted to know if we can set default directory that the loader can use. this requirement is basically to enable all the clients to upload the data placed on the server and use the loader utility.
    thanks in advance,
    Basavraj

    Ella,
    You don't say which version of SQL Developer you are using via Citrix, but just setting the SQLDEVELOPER_USER_DIR hasn't worked for a long time (see Re: SQLDEVELOPER_USER_DIR does not function anymore). Also, since version 1.5, the default for the user directory (now set via ide.user.dir as shown below) is under the user profile area (relative to %APPDATA%), which you should be able to write to, even on Citrix.
    Assuming that neither of those help, you will need to get whoever installed SQL Developer on the Citrix C: drive to modify the sqldeveloper.conf to have a line like, where the path exists for everyone who will be using the shared SQL Developer (assumes everyone has a H: drive):
    AddVMOption -Dide.user.dir=H:\sqldeveloperAn alternative (depending on how you start SQL Developer via Citrix), is to create your own shortcut to start SQL Developer with something like:
    sqldeveloper -J-Dide.user.dir="%SQLDEVELOPER_USER_DIR%"theFurryOne

  • Format input for Sql*Loader

    I have a problem in formating an input file for Sql*Loader
    The file has the following format:
    1 Jeff
    2 Kyle
    3 Tom
    1 Lisa
    2 Bryan
    3 Max
    4 Rob
    5 Steve
    1 Richard
    2 Mary
    and so on
    the file should look as follows to process with Sql*Loader:
    1 Jeff 2 Kyle 3 Tom
    1 Lisa 2 Bryan 3 Max 4 Rob 5 Steve
    1 Richard 2 Mary
    any suggestions?
    Edited by: royce on Sep 18, 2008 2:08 AM

    royce wrote:
    I have a problem in formating an input file for Sql*Loader
    The file has the following format:
    1 Jeff
    2 Kyle
    3 Tom
    1 Lisa
    2 Bryan
    3 Max
    4 Rob
    5 Steve
    1 Richard
    2 Mary
    and so on
    the file should look as follows to process with Sql*Loader:
    1 Jeff 2 Kyle 3 Tom
    1 Lisa 2 Bryan 3 Max 4 Rob 5 Steve
    1 Richard 2 Mary
    any suggestions?
    Edited by: royce on Sep 18, 2008 2:08 AMActually, looking at your data again, you don't have a consistent format, so this makes it really difficult for something like SQL*Loader to process. If there were just e.g. 3 rows per record then that would be simple, but you are expecting SQL*Loader to look ahead to determine if there is more data or if it's reached the end of the record.
    You would be better to load the data (external tables would probably make it quicker and easier as the data will come in the order as it is specified in the file, which would help as you have no group identifier against the sets of records) as it is and then use SQL to process them.
    You haven't specified the resulting table that the data is loaded into. Is that just one single VARCHAR column with all the data concatenated or is it several columns (one for each name)?

  • Script for sql*loader

    Hi All,
    I am loading the data from .csv format to table by using sql*loader.
    This sql*loader command was existed in one of the pl/sql Procedure. this procedure will first create a table and then it will get the data by using sql*loader command,then one procedure will run.
    to run this script we are manually loading the data from excel by using sql*laoder by running the .ctl command from Command prompt.. instead of doing manually this process is there any other way to do it automatically.
    if it is possible please let me know.
    here i am giving the script
    drop table emp;
    create table emp
    (eno number,
    ename  varchar2(20),
    job varchar2(20),
    sal number(4),
    doj date
    - here table created.then here by using below sql*loader command loading the data info emp table
    load data
    infile <file path>
    fields terminated by ','
    intto table emp
    (eno,
    ename,
    job,
    sal)by running this control file manually from command prompt loading the data.
    then there is a procedure which we need to to update the EMP table.
    for this whole thing we are just running the script except loading the data part.
    for this please let me know the automation part.
    Thanks.

    Hi,
    Create a shell Script(Unix) or Windows batch Job to automate the entire process. The script will like below
    1.Connect SQLPLUS with the Createtable.SQL file (The Createtable.sql will have the create table script)
    2.invoke sql loader with the control file
    3.then again connect SQLPLUS with the executeproc.sql file (the executeproc.sql will have the execute command to execute the stored procedure)
    by this way your entire process can be in one script and automate by scheduling it in unix or windows.
    Thanks,
    Vijay
    Edited by: Vijayaraghavan Krishnan on Nov 27, 2012 4:48 PM

  • Unable to generate "Export data source" for Master data infoobject

    Hi Gurus,
    I'm in BW 3.5
    I need to generate "Export data source" for a master data info object.
    I followed below steps:
        I ticked the checkbox "Characterist. is export data source" in the master data Info object maintenance screen.
        In the Infosource area, for the desired Infoobject --> Right click --> Generate export datasource --> a dialog box displays saying "The generation of DataSource  was successful"
    Problem:
    Even after refreshing, etc.. I couldn't find the generated datasource 8**** for the above master data. I also tried to replicate the datasource from the myself source system, but couldn't find it even there. I don't know where the generated export data source is hiding ???
    Could anyone please help ????
    Thanks,
    Venkat

    Hi Venkat,
    I guess that after creating an export datasource for infoobject this DS should appear in the RSA1-Source systems - MYSELF - datasource overview (with name starting with 8). Since it's a datamart, it should appear also as system generated infosource. And in this case you would be able to assign in URs of data target the appropriate infosource (make sure that in Infoproviders tab of RSA1 you have inserted your infoobject as a data target).
    However, there are some bugs related to export data source. CHeck if you see you export data source in RSA6.
    If you don't see it - consider applying OSS Note #816892 - "30BSP26: Export DS for master data is not generated".
    Note #876845 - "30BSP29: InfoObject change: Export DataSource not adjusted" is also may be useful.
    -Vikram

  • Can we use Data Pump to export data, using a SQL query, doing a join

    Folks,
    I have a quick question.
    Using Oracle 10g R2 on Solaris 10.
    Can Data Pump be used to export data, using a SQL query which is doing a join between 3 tables ?
    Thanks,
    Ashish

    Hello,
    No , this is from expdp help=Y
    QUERY                 Predicate clause used to export a subset of a table.
    Regards

  • Import/export data from ms sql 7 to xml file in a particular xpdl format

    I'm trying to write java program to import/export data from ms sql 7 to xml file in a particular xpdl format. Can anyone suggest how to do it?

    take a glance at what these guys do: http://www.openbusinessengine.org/docs/guide.html

  • Concatenate positions in control file for sql*loader utility.

    Is there a way to concatenate several character positions in a control file for sql*loader???
    example... field1 position(1:3) || position(5:7) ????
    I would rather not create any unnecessary temp tables for a straight load...

    How about...
    /code
    field1 position(1:7) char "substr(:field1, 1, 3) || substr(:field1, 5)"

  • Why no exclusive lock for conventional path loading for SQL*Loader?

    why no exclusive lock for conventional path loading for SQL*Loader?
    it use insert statement so it should use exclusive lock right?
    thanks

    ok, so only update statement would put a lock but not for insert statement?
    because I have seen a situation where a user update rows in a sesssion (without commit) prevent another user update the rows.
    thanks

  • Question for SQL Loader / IMP /EXPORT

    hi all,
    i just describe my example first : -
    TABLE A have five columns.
    a_column,b_column,c_column,d_column,e_column.
    and have 1000 records.
    i want to remove c_column & e_column and add f_column.
    on TABLE A. which method (SQL Loader or IMP/EXP) is good suggestion for export & import data before take above action.
    boris

    Export/Import is the most appropiate solution for the task that you want to carry out because SQL*Loader is designed to load data into the database from flat files.
    Regarding how to drop the two columns , you can do it
    directly if you are working in 9i setting both columns as
    unused after drop unused columns in the table.
    Complete reference for those utilities:
    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96652.pdf
    Joel P�rez

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

  • SQL DEVELOPER 1.5.3: Export Data options for using SQL to write SQL?

    I write a lot of SQL that generates SQL. In a competitor's product, I can export query results (Export > Save As > Tab Delimited) to the clipboard, paste the generated SQL into a new window, then execute the generated SQL.
    In SQL Developer, using Export Data > Text to the clipboard, it's delimiting each row with double-quotes. Is there any way to turn this behavior off to achieve what I want? Or should I be choosing a different export format?
    For now, I can do a search/replace to eliminate the double-quotes,
    Thanks.
    Dana

    Dana,
    I probably haven't done this with generating thousands of SQL lines, but I have certainly used the Ctrl-A, Ctrl-C (or Ctrl-Shift-C to get headers) to copy thousands of records of result data. Note that the Ctrl-A forces a fetch of all remaining records that have not yet been fetched, which may add to the time taken by the process - for example, running the query fetches the first 50 records and then Ctrl-A will fetch the remaining records as well as selecting them all, however long that takes. Also, there is a noticeable delay with the Ctrl-C for thousands of records - only rough counting but I was seeing a UI freeze for ~ 4 seconds when copying 10000 records from a query with around 30 columns in it (pasting the clipboard into a file produced a file just under 4MB).
    theFurryOne

  • While creating the Data source for Sql server am getting this error?

    Hi i new to Power BI sites and office 365,
    For my first step 
    1. i have successful creaeted Gateway in Office 365
    2.Now i have creating  the Data source for that gateway using Sql server R2
    3.While Creating the Data source using the Corresponding gateway i have given and next phase set Credentials  phase i have noticed one pop up window and it will shows me like
    Data source Settings and  below in that window it will show's u the things like 
    Datasource Name.
    Loading......
    Credentials type:
    Privacy Level:
    Failed to verify parameter
    I will get this results finally  ,so hw should i achive this probelm ,Please let me know if any one knows
    So kindly give me the proper answer for this.
    Regards

    Any suggestions for Chinnarianu?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

Maybe you are looking for