Reading an EXCEL file from Oracle PL/SQL (HP-Unix server)

Hi,
I have the following requirement:
1. Get the EXCEL file from the remote FTP location
2. Read the EXCEL file and convert it into the CSV file format.
3. Put the CSV file into another FTP location.
I need to get all these points done using Oracle PL/SQL procedure.
I am using the Oracle 9i installed in HP-Unix environment.
Please help me in getting this done.
Thanks

Ok, setting up Excel as an External Database connection....
1- Go to Control Panel>Administrative Tools>Data Sources (ODBC)>System DSN and create a data source with appropriate driver. Name it EXCL.
2- In %ORACLE_HOME%\Network\Admin\Tnsnames.ora fie add entry:
EXCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.0.24)(PORT = 1521))
(CONNECT_DATA =
(SID = EXCL)
(HS = OK)
Here SID is the name of data source that you have just created.
3- In %ORACLE_HOME%\Network\Admin\Listener.ora file add:
(SID_DESC =
(PROGRAM = hsodbc)
(SID_NAME = <hs_sid>)
(ORACLE_HOME = <oracle home>)
under SID_LIST_LISTENER like:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = d:\ORA9DB)
(PROGRAM = extproc)
(SID_DESC =
(GLOBAL_DBNAME = ORA9DB)
(ORACLE_HOME = d:\ORA9DB)
(SID_NAME = ORA9DB)
(SID_DESC =
(PROGRAM = hsodbc)
(SID_NAME = EXCL)
(ORACLE_HOME = D:\ora9db)
Dont forget to reload the listener
c:\> lsnrctl reload
4- In %ORACLE_HOME%\hs\admin create init<HS_SID>.ora. For our sid EXCL we create file initexcl.ora.
In this file set following two parameters:
HS_FDS_CONNECT_INFO = excl
HS_FDS_TRACE_LEVEL = 0
5- Now connect to Oracle database and create database link with following command:
SQL> CREATE DATABASE LINK excl
2 USING 'excl'
3 /
Database link created.
Now you can perform query against this database like you would for any remote database.
SQL> SELECT table_name FROM all_tables@excl;
TABLE_NAME
DEPT
EMP
But you're limited to Windows based servers for this.
As for converting Excel to CSV and doing it yourself. I hope you know the internal format of MS Excel files cos you're gonna need to know it. It would be far easier if the "user" creating the Excel file could save a copy out in CSV format for you and then it's just a case of FTP'ing the file and using external tables to read the data.

Similar Messages

  • Read an EXCEL file from application server

    Hi all
    I have to read an excel file from applicatin sever and update my custom tablels.
    The problem is when the file is uploaded into the application server .
    the fields it has are
    name age gender
    xyz    67  m.
    when seeing the file using al11 tcode :
    its showing the following:
    ###&#2161;##################>#######################################################################################################################
    #################################################################O#b#j#I#n#f#o################################################################
    How do i read this and put in my internal table
    Pleaes help.
    Thanks and Regards,

    Hi,
    I am using ECC6.0.
    I think the EXCEL file is stored in compressed format to save space.
    Please let me know how to decompress etc.
    I tried using the function moduel
    text_convert_xls_to_sap.
    How do I pass the parameter to I_filename.
    Regards,

  • Error While reading an Excel file from KM Folder.

    Hi Guru's,
    In my PDK Application I am trying to read an Excel file from KM Folder.
    Workbook workbook = Workbook.getWorkbook(new File("/irj/go/km/docs/documents/test/Test.xls"));
    It gives an error:
    Error:java.io.FileNotFoundException: \irj\go\km\docs\documents\test\Test.xls (The system cannot find the path specified)
    Details of appli:
    In my JspDynpage I am calling a utility Java file.
    There I have to read an  Excel and to passit to JSP.
    Details of jar files  used:
      jxl-2.6
      com.sap.security.api.jar
    Regards,
    Ram

    Hi,
    You are trying to read file wrong way. In the tutorial of Java Excel Api: "JExcelApi can read an Excel spreadsheet from a file stored on the local filesystem or from some input stream.". You are trying to read from file system. So you must get file input stream then you can read it. Please search forums KM file read.

  • Open Excel File from oracle directory on a local machine

    Hi,
    I have an application where I generate a excel using data in a table and write excel file in oracle directory.Now my requirement is to open that file from local machine .How can i achieve it.
    I am using Apex 4.2,Oracle 10g .
    Thanks
    Rajan.C
    Edited by: Rajanjai on May 31, 2013 5:34 PM

    Close your question here and open here
    Oracle Discussion Forums » Oracle Database » Application Express

  • Update Existing Excel File from Oracle DB

    The user has an Excel Sheet that they populate manually.
    There is a application that pulls data from salesDB.
    Target : Eliminate the manual updating process of DB.
    Solution:
    1.Add a Button o VB .NET application like "Generate Report"
    2. Create DB connectivity to that Excel sheet and make it pull values from DB instead of manual entry
    So that button should produce an Excel document with updated fields reading from salesDB
    Questions
    1. Which solution is better?
    2. what would be the step by step approach for each solution ?
    3. Any link to articles that talk about Excel report generation from Oracle would be great.
    -- New to oracle

    Hello,
    if you need more than a simple csv file then you can find free tools at
    https://xml-spreadsheet.samplecode.oracle.com/ or
    https://exceldocumenttype.samplecode.oracle.com/
    While they both use a MS XML format they differ in the way they return the output file
    - write with utl_file (1)
    - return a CLOB (1 and 2)
    - directly to a web browser through a PL/SQL DAD (2)
    - via a user defined type (2)
    Regads
    Marcus

  • Has anybody downloaded the student schema file from oracle pl/sql by benjam

    from a newbie:
    where is the file for the 3rd edition?

    This works for me:
    PROCEDURE A_DATA_B( p_ID IN SCHEMA2.TABLE1.ID@dblink%TYPE, 
                        p_MATCH IN SCHEMA2.TABLE2.MATCH@dblink%TYPE,  
                        p_STATUS IN SCHEMA2.TABLE3.STATUS@dblink%TYPE,   
                        p_MSG IN SCHEMA2.TABLE1.MSG@dblink%TYPE,  
    Alternatively create a synonym for the table (you can't create a synonym for a schema):
    create synonym ref_table1 for SCHEMA2.TABLE1.ID@dblink
    PROCEDURE A_DATA_B( p_ID IN REF_TABLE1.ID%TYPE, 
                        p_MATCH IN REF_TABLE2.MATCH%TYPE,  
                        p_STATUS IN REF_TABLE3.STATUS%TYPE,   
                        p_MSG IN REF_TABLE1.MSG%TYPE, 
    but I don't like the idea of depending on a schema in another instance at all.
    Can you create a reference set of tables in a schema on the current database, to be the source for the data types?

  • Display excel file from jsp

    hi i am trying to read an excel file from a location on the app server and display it in the browser (ie). the excel file should open up and not display the open/save dialog.
    following is the code that i am using. i am not able to get it to work. getting an illegalstateexception and also i am getting all garbage diplayed in the browser. no excel. kindly help.
    <%@ page import="java.io.*" contentType="application/vnd.ms-excel"%>
    <%@ taglib uri="/WEB-INF/tlds/sapphire.tld" prefix="sapphire" %>
    <%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
    <%
    //response.reset();
    //response.setHeader("Pragma", "no-cache");
    //response.setHeader("Cache-Control", "no-cache");
    //response.setDateHeader("Expires", 0L);
    ServletOutputStream so = response.getOutputStream();
    String filename = "C:\\example1.xls";
    String mimetype = "application/vnd.ms-excel";
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    InputStream in = new BufferedInputStream(new FileInputStream(filename));
    byte bytebuff[] = new byte[500];
    for(int lengthread = 0; (lengthread = in.read(bytebuff)) != -1;){
    output.write(bytebuff, 0, lengthread);
    byte data[] = output.toByteArray();
    response.setContentType(mimetype);
    so.write(data);
    in.close();
    so.close();
    %>

    A JSP calls getWriter() by default.
    Every time you have a carriage return outside <% %> it gets written to the writer.
    The Illegal state exception would be because you are getting the outputStream after the writer.
    This is better done in a servlet, but can be done in a JSP, try it with code like this:
    <%@ page import="java.io.*" contentType="application/vnd.ms-excel"
    %><%@ taglib uri="/WEB-INF/tlds/sapphire.tld" prefix="sapphire"
    %><%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c"
    %><%
    %> Note that there is no text at all outside of the <% %> (not even carriage returns)
    Also, why are you writing to a ByteArrayOutputStream (ie into a memory byte array), and then writing the byte array to the servletoutputstream?
    Just put a buffer around the servlet outputstream and write directly to that.
    ServletOutputStream so = response.getOutputStream();
    BufferedOutputStream output = new ByteArrayOutputStream(so);
    ...

  • How can I read an excel file .xls from an forms 6i

    Hi
    I have forms6i and webutil don t work with this version, can I read an excel file from forms6i.
    Thank u

    Hi hosoriol,
    You can refer an excel as an external table first using the steps below and then you can start reading from it.
    If you want to update the excel file then create an view and create instead of triggers for it.
    Steps
    h3. 1.[Create an external table for the excel file |http://www.adp-gmbh.ch/ora/misc/ext_table.html|Click here to view detailed description]
    h4. 1. Create a directory in Oracle where you have kept the xls file
    create or replace directory ext_dir as '/home/rene/ext_dir';h4. 2. grant read, write on directory ext_dir to scott;
    h4. 3. creating the external table
    create table ext_table_csv (
                                                i   Number,
                                                n   Varchar2(20),
                                                m   Varchar2(20)
                     organization external (
                                                     type   oracle_loader
                                                     default directory ext_dir
                                                    access parameters (
                                                                                 records delimited  by newline
                                                                                 fields  terminated by ','
                                                                                  missing field values are null
                                                   location ('file.csv')
                     reject limit unlimited;
    Note_
    If you want to update the excel file then create a view and then create the instead of triggers to do the update, delete or insert.[Creating views on external tables | http://www.dba-oracle.com/oracle_news/2005_9_1_updating_external_tables.htm]
    h3. 2. Use the data block wizard and connect to the corresponding schema and create a database block.
    Kindly click Correct or Helpful if it helps Thanks :-)

  • Error while reading excel file from application server into internal table.

    Hi experts,
    My requirement is to read an excel file from application server into internal table.
    Hence I have created an excel file fm_test_excel.xls in desktop and uploaded to app server using CG3Z tcode (as BIN file type).
    Now in my program I have used :
    OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    DO.
    READ DATASET v_filename INTO wa_tab.
    The statement OPEN DATASET works fine but I get a dump (conversion code page error) at READ DATASET statement.
    Error details:
    A character set conversion is not possible.
    At the conversion of a text from codepage '4110' to codepage '4103':
    - a character was found that cannot be displayed in one of the two
    codepages;
    - or it was detected that this conversion is not supported
    The running ABAP program 'Y_READ_FILE' had to be terminated as the conversion
    would have produced incorrect data.
    The number of characters that could not be displayed (and therefore not
    be converted), is 445. If this number is 0, the second error case, as
    mentioned above, has occurred.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
    caught and
    therefore caused a runtime error.
    The reason for the exception is:
    Characters are always displayed in only a certain codepage. Many
    codepages only define a limited set of characters. If a text from a
    codepage should be converted into another codepage, and if this text
    contains characters that are not defined in one of the two codepages, a
    conversion error occurs.
    Moreover, a conversion error can occur if one of the needed codepages
    '4110' or '4103' is not known to the system.
    If the conversion error occurred at read or write of  screen, the file
    name was '/usr/sap/read_files/fm_test_excel.xls'. (further information about
    the file: "X 549 16896rw-rw----201105170908082011051707480320110517074803")
    Also let me know whether this is the proper way of reading excel file from app server, if not please suggest an alternative .
    Regards,
    Karthik

    Hi,
    Try to use OPEN DATASET v_filename FOR INPUT IN BINARY mode encoding default. instead of OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    As I think you are uploading the file in BIN format to Application server and trying to open text file.
    Regards,
    Umang Mehta

  • How to read an excel file in webdynpro application

    Hello Experts,
    Can someone please tell me how to read an excel file in a webdynpro application?
    There is a tutorial for how to write contect into an excel, but i want to read the excel.
    Can someone help please !!
    Thanks and Kind regards,
    G.Singh.

    Hello Experts,
    I have done all the given above.
    I want to read a excel file from KM. My code is as below
    ResourceContext resourceContext = buildResourceContext();
    IResourceFactory resourceFactory = ResourceFactory.getInstance();
    RID pathRID = RID.getRID("/documents/ExcelReport.xls");     
    IResource resource =     resourceFactory.getResource(pathRID, resourceContext);
    Workbook wb = Workbook.getWorkbook(resource.getURI().getPath());
    Sheet sh = wb.getSheet(0);
    int columns = sh.getColumns();
    int rows = sh.getRows();
    wdComponentAPI.getMessageManager().reportSuccess(" Rows: " + rows);
    wdComponentAPI.getMessageManager().reportSuccess(" Columns: " + columns);
    This does not give me the excel file form the KM
    Can you please just what i can do at this point?
    Kind Regards,
    G Singh.

  • Read a excel file...Not working in sap portal environment

    Hi,
    I have a requirement to read an excel file from presentation server. I have used funtion module TEXT_CONVERT_XLS_TO_SAP. This is working in production system.
    But this read is failing in PORTAL environment as i am getting an error " excel file cannot be processed".
    Please let me know if anyone knows how to solve this issue...
    Regards,
    San

    Dear Shankar,
    I can see the form in R3 using asr_process_execute application but not in portal.
    one of most strangest error I have seen.

  • How can I read the EXCEL file while Program is running in background.

    Hi all Expert,
    How can I read the EXCEL file while Program is running in background.
    Thanks

    you need to place ur excel file on application server and follow this thread: Reading an Excel file from the application server?
    loots of information if you can search forum.. thanks

  • Upload data from excel file to Oracle table

    Dear All,
    I have to upload data from excel file to Oracle table without using third party tools and without converting into CSV file.
    Could you tell me please how can i do this using PLSQl or SQL Loader.
    Thnaks in Advance..

    Dear All,
    I have to upload data from excel file to
    Oracle table without using third party tools and
    without converting into CSV file.
    Could you tell me please how can i do this
    using PLSQl or SQL Loader.
    Thnaks in Advance..As billy mentioned using ODBC interface ,the same HS service which is a layer over using traditional ODBC to access non oracle database.Here is link you can hit and trial and come out here if you have any problem.
    http://www.oracle-base.com/articles/9i/HSGenericConnectivity9i.php[pre]
    Khurram                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • Uses the library to get UTL_FILE to read a excel file in PL SQL?

    Good day.
    Someone can give me some code that uses the library to get UTL_FILE to read a excel file in PL SQL?
    I intend to use this library because I want to run a script on my machine to treat an excel file without having to make changes on the server.
    Thank you.

    163d6dc5-fa66-4eb1-b7d5-653dea63bbc8 wrote:
    Good day.
    Someone can give me some code that uses the library to get UTL_FILE to read a excel file in PL SQL?
    I intend to use this library because I want to run a script on my machine to treat an excel file without having to make changes on the server.
    Thank you.
    Ranit's links are useful, you should read them.
    Also check out the FAQ on this forum:Re: 5. How do I read or write an Excel file?
    UTL_FILE is not the best choice for reading data from Excel files.
    It also will not be able to read an Excel file located on your client computer.  As with any PL/SQL code on the database, it can only access things that the server itself can see, so that doesn't include hacking across the network, bypassing network security, and hacking into the client computers operating system to read files directly from it's hard disk.  This isn't how client server architecture is intended to work.

Maybe you are looking for

  • How to set jpeg resolution when saving pdf file as jpeg

    I'm running Acrobat using interprocess api, I can invoke a script to save a pdf file as JPEG, but I need to be able to set the resolution of the saved jpeg file. Any clues as to how I can do that ? Peter

  • Touch screen on HP Envy 120 printer

    My touch screen on my HP Envy 120 printer does not light up.  The printer turns on and I can print from my computer but unable to scan or copy a hard copy document from the touch screen.  Is there an easy fix for this or do I need to return the print

  • Editing xml in java

    hello everybody, i'm trying to write a java application for editing xml documents. I know It is possible to use xsl stylesheets to transform xml documents but it is possible to display the result of the transformation process in java? I mean, I make

  • C++ COM Catch Return Events

    I have been using the C++ COM iTunes Interface for a while in my application to import files into iTunes via the SDK. This has been working fine for a couple of years now however I have come across an issue with the deployment of iTunes 9 and greater

  • In Windows7 (64bit) Firefox becomes unresponsive and the vertical scroll turns black before the crash.

    I have about 30 crashes with the plugins disabled. This usually happens with two to three tabs open.