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

Similar Messages

  • SQL*Loader in JSP

    SQL LOADER in JSP i know Oracle 10g have a utility sqlldr
    Can i submit file(CSV) from a remote client to server which can be than upload into Oracle DB.
    i know how to upload file into root directory
    How can i use JSP to run sqlldr on server so that the process become automatic.
    I know how to give command sqlldr in Command prompt but what is the scripting on JSP so that sqlldr can run and csv file get uploaded.
    where from i can info about it please let me know if you have any idea
    thanks
    Message was edited by:
    UDAY

    Hi
    Can you please check that is it possible to execute OS commands in JSP ??
    If possible then you can very well execute SQLLDR in JSP .
    thanks
    Note : This is Oracle database general forum.

  • Retrieve image from my sql database using jsp

    I want to retrieve image from my sql (blob type) & save it in given relative path in server .(using jsp and servlets)
    please give me some sample codes.

    PreparedStatement pst = null;
      ResultSet rs=null;
    pst = conn.prepareStatement("select image from imagedetails where imageid='"+imageid+"'");
    rs=pst.executeQuery();
    while(rs.next())
                                byte[] b=rs.getBytes("image");
                                FileOutputStream fos=new FileOutputStream("c://image.jpg");
                                fos.write(b);
                            } hi this the code to retrieve the image from DB and write to a file.

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

  • 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

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

  • 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

  • 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 :)

  • Regarding execution of pl/sql procedure using JSP

    HI all
    Please help me.
    i am customizing a jsp page ,which is executing one sql procedure first then selecting data from the table in which procedure is inserting.
    How can i pass parameter dynamically to the sql procedure ? ,which i am getting from an HTML page.
    Please help me out.
    regards
    satendra

    this is the sample code provided by oracle.
    * This sample shows how to call PL/SQL blocks from JDBC.
    import java.sql.*;
    class PLSQL
    public static void main (String args [])
    throws SQLException, ClassNotFoundException
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    String url = "jdbc:oracle:oci8:@";
    try {
    String url1 = System.getProperty("JDBC_URL");
    if (url1 != null)
    url = url1;
    } catch (Exception e) {
    // If there is any security exception, ignore it
    // and use the default
    // Connect to the database
    Connection conn =
    DriverManager.getConnection (url, "scott", "tiger");
    // Create the stored procedures
    init (conn);
    // Cleanup the plsqltest database
    Statement stmt = conn.createStatement ();
    stmt.execute ("delete from plsqltest");
    // Close the statement
    stmt.close();
    // Call a procedure with no parameters
    CallableStatement procnone = conn.prepareCall ("begin procnone; end;");
    procnone.execute ();
    dumpTestTable (conn);
    procnone.close();
    // Call a procedure with an IN parameter
    CallableStatement procin = conn.prepareCall ("begin procin (?); end;");
    procin.setString (1, "testing");
    procin.execute ();
    dumpTestTable (conn);
    procin.close();
    // Call a procedure with an OUT parameter
    CallableStatement procout = conn.prepareCall ("begin procout (?); end;");
    procout.registerOutParameter (1, Types.CHAR);
    procout.execute ();
    System.out.println ("Out argument is: " + procout.getString (1));
    procout.close();
    // Call a procedure with an IN/OUT prameter
    CallableStatement procinout = conn.prepareCall ("begin procinout (?); end;");
    procinout.registerOutParameter (1, Types.VARCHAR);
    procinout.setString (1, "testing");
    procinout.execute ();
    dumpTestTable (conn);
    System.out.println ("Out argument is: " + procinout.getString (1));
    procinout.close();
    // Call a function with no parameters
    CallableStatement funcnone = conn.prepareCall ("begin ? := funcnone; end;");
    funcnone.registerOutParameter (1, Types.CHAR);
    funcnone.execute ();
    System.out.println ("Return value is: " + funcnone.getString (1));
    funcnone.close();
    // Call a function with an IN parameter
    CallableStatement funcin = conn.prepareCall ("begin ? := funcin (?); end;");
    funcin.registerOutParameter (1, Types.CHAR);
    funcin.setString (2, "testing");
    funcin.execute ();
    System.out.println ("Return value is: " + funcin.getString (1));
    funcin.close();
    // Call a function with an OUT parameter
    CallableStatement funcout = conn.prepareCall ("begin ? := funcout (?); end;");
    funcout.registerOutParameter (1, Types.CHAR);
    funcout.registerOutParameter (2, Types.CHAR);
    funcout.execute ();
    System.out.println ("Return value is: " + funcout.getString (1));
    System.out.println ("Out argument is: " + funcout.getString (2));
    funcout.close();
    // Close the connection
    conn.close();
    // Utility function to dump the contents of the PLSQLTEST table and
    // clear it
    static void dumpTestTable (Connection conn)
    throws SQLException
    Statement stmt = conn.createStatement ();
    ResultSet rset = stmt.executeQuery ("select * from plsqltest");
    while (rset.next ())
    System.out.println (rset.getString (1));
    stmt.execute ("delete from plsqltest");
    rset.close();
    stmt.close();
    // Utility function to create the stored procedures
    static void init (Connection conn)
    throws SQLException
    Statement stmt = conn.createStatement ();
    try { stmt.execute ("drop table plsqltest"); } catch (SQLException e) { }
    stmt.execute ("create table plsqltest (x char(20))");
    stmt.execute ("create or replace procedure procnone is begin insert into plsqltest values ('testing'); end;");
    stmt.execute ("create or replace procedure procin (y char) is begin insert into plsqltest values (y); end;");
    stmt.execute ("create or replace procedure procout (y out char) is begin y := 'tested'; end;");
    stmt.execute ("create or replace procedure procinout (y in out varchar) is begin insert into plsqltest values (y); y := 'tested'; end;");
    stmt.execute ("create or replace function funcnone return char is begin return 'tested'; end;");
    stmt.execute ("create or replace function funcin (y char) return char is begin return y || y; end;");
    stmt.execute ("create or replace function funcout (y out char) return char is begin y := 'tested'; return 'returned'; end;");
    stmt.close();
    }

  • How to connect to MS SQL server using JSP?

    Hi, i am new to JSP so i would like to know what is the code to create a connection to MS SQL server.
    I am using jakarta-tomcat 4 as my server.
    sorry for any inconvenient....
    pls help me....

    This works to start off with but there are more sophisticated/ different ways of doing things,for instance it's best not to access the db via your jsp, rather do this logic in JavaBeans, Servlets or use Struts.Therefore, it's best that you consult with others and find out which is best way to go about creating your web apps.
    Here's some code:
    In my jsp's I access the bean below , instantiate a statement object and go on from there:
    *SOME of the code in the JSP's.
    //create bean instance
    <jsp:useBean id='dbConn' class='projectsevenhouses.DatabaseConnectionBean ' scope='session' />
    //instantiate statement
    Statement st = dbConn.getConnection().createStatement();
    * JavaBean
    package projectsevenhouses;
    public class DatabaseConnectionBean implements Serializable {   
    private Connection conn;
    private Statement st;
    private String dbURL = "jdbc:odbc:datasource";
    private static String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    /** Creates a new instance of DatabaseConnectionBean */
    public DatabaseConnectionBean() {
    makeConnection();
    public void setDatabaseName(String dbName) {
    dbURL = dbName;
    private void makeConnection() {
    try {
    Class.forName(driver);
    conn = DriverManager.getConnection(dbURL,"sa","");
    } catch (SQLException e) {
    System.out.println("SQL Cause ->" + e.toString());
    } catch (ClassNotFoundException cnf) {
    System.out.println("Class Not Found:" + cnf);
    public Connection getConnection() {
    if (conn == null) {
    makeConnection();
    return conn;
    public void setCloseConnection(boolean close) {
    if (close) {
    try {
    conn.close();
    } catch (Exception e) {
    conn = null;
    Hope it gives u an idea...
    Ciao
    Ushanta

  • SQL*Loader use of sequence

    I need to use a loader script to "append into" two tables. The first insert needs to generate a sequence.nextval. I understand how to do this:
    LOAD DATA
    INFILE 'test.in' "var 2"
    APPEND INTO TABLE customerinfo
    FIELDS enclosed BY "|"
    (CUSTOMERINFOID "customerinfoid_seq.nevtval",)....
    Then I need to use that same sequence value to insert into the second table. Can you return the nextval for subsequent use by the loader? Thanks in advance,
    Tia

    use seqname.CURRVAL to get that same value, but must get it before the next seqname.nextval is used. Maybe you could load a temp table and load the final table with cursor logic (insert table one from nextval, insert table two from currval), OR if the records are of equal number and in exactly the same order, you could chance using a SECOND sequence.

  • Can we schedule Loader Jobs (SQL Loader) using Grid Control  ?

    Can we schedule SQL Loaders jobs/process using Grid Control for 11g database ?
    Or
    Is it good to schedule it as external jobs using DBMS_SCHEDULER ?
    OS is LINUX. Database is 11g R1 Grid Control will be the latest, I believe 10gR3.
    Any other suggestions... (I know it can be done using OS utilities like cron and others but that is not an option for now.)
    Thanks in advance.

    Try this
    -> Create a shell script to execute sqlldr
    -> On Grid, create an "OS COMMAND" job and pass this script as parameters. You'll have options to schedule this job.
    Let us know how it works.

  • Using jsp:include in showOneTab - main form not loaded on submit

    I have a JSP page with JSF and ADF components. It is a large JSP containing some main details and then an af:showOneTab component to create a set of tabs. It works fine with JDK 1.5 and Tomcat 5.0 but when changed to Oracle Application Server 9.0.4 and JDK 1.3 We get the following error:
    JspCompileException:.... code too large for try statement catch( Throwable e}....
    Finding this to be caused by large size of JSP, we divided the page as follows - a main jsp containing the main form details and 1 jsp for each tab. Whenever one of the tabs is clicked the corresponding JSP is dynamically loaded using jsp:include tag as follows:
    <af:showDetailItem text="Tab1" id="tab1" styleClass="menu">
              <f:subview id="viewTab1">
                   <jsp:include page="Tab1.jsp" />
              </f:subview>
    </af:showDetailItem>
    There is a Submit button in the main jsp, when this is clicked the main jsp is reloaded.
    But when the user navigates to any of the tabs and then clicks the Submit button in the main form, the main form is not reloaded - only the jsp for the currently selected tab is loaded.
    (I am using f:view and h:form in the main form, and no form tag in the included jsps)
    How to solve this problem?

    The af:selectOneChoice components are in the test.jsp page included in main.jsp with jsp:include tag.
    The code look like this:
                   <af:selectOneChoice label="#{msg.team}"
    id="soc1"
    value="#{myBean.selectedTeamID}"
    autoSubmit="true">
    <f:selectItems id="si1" value="#{myBean.teamList}"/>
    </af:selectOneChoice>
    <af:selectOneChoice label="#{msg.subteam}"
    id="soc2"
    value="#{myBean.selectedSubteamID}"
    partialTriggers="soc1"
    rendered="#{myBean.selectedTeamID!=null}"
    autoSubmit="true">
    <f:selectItems id="si2" value="#{myBean.subteamList}"/>
    </af:selectOneChoice>
    the code works fine in the seperate page, but when I include the page the second selectOneChoice component doesnt get rendered.
    Edited by: Migan on 2010-jul-13 08:36

Maybe you are looking for