Excel to oracle tables automation

Hi Gurus,
I want to load data from excel(data exist for each table/Tab in the file) into oracle tables(unix environment). Loading should be done using sqlldr and with proper error handling.
How can I implement this automation process.?
Thanks in advance.

Hi,
I am using oracle 10g on the server side, and on the client machine only oracle client software installed. I will have the excel with different spreadsheets per table on the same client machine. can you help me in this scenario, as I dont have personal experience to automate the things like this.
Thanks

Similar Messages

  • Upload data from excel to oracle table

    Hi,
    if i'm user and using an application and i want to upload data from excel to oracle table on button click . Is it possible by using sql loader.
    If yes then please clarify it .
    is it possible from client end.
    thanks
    kam

    Yes it is possible using SQL*LDR, External tables and ORCL Export Utility. Though I didn't try Export Utility to load the external files.
    SQLLdr sysntax:
    Create a control file.
    It looks like this
    Load data
    Infile 'source.dat' 
    Into Table tablename
    Fields terminated by ',' optionally enclosed by '"'
    {code}
    then use sqlldr command from your OS.
    {code}
    sqlldr userid/password@sid control = filename.ctl, data = source.dat, log = logname.log, bad = badname.log, discard = discardname.discard
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Transfer data from MS Excel to Oracle table

    Hello,
    hope someone can help: What is the easiest way to transfer data from Excel sheet to a Oracle table and how ?
    An example of a row to transfer is given below
    Date Time Value 1 Value 2
    2004-02-02     03:47:39     9,62     3,62     
    Thanks in advance
    Regards
    Roar

    From Microsoft access , import data from Excel to an Access table.
    Format that Access Table properly in Design mode.
    Create a table as per your specification in oracle Database.
    Then export to oracle from access using approppriate ODBC driver.
    --Sayan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Format Excel sheet - Oracle COM Automation

    Dear gentlemen,
    I would like to get your help to generate a formatted excel sheet using Oracle COM Automation, I may don’t know the correct properties to use, or don’t know how to use it.
    For example:
    To set a cell value I use this line:
    hresult:=Ordcom.SetProperty(RangeHandle, 'Value', data, 'BSTR');
    and when I tried to fill the same cell with a yello color I used this line:
    hresult:=Ordcom.SetProperty(RangeHandle, 'Interior.Color', 65535, 'BSTR');
    but that has no effect at all, so please advise what is wrong, this may apply also for the most properties such as “Font.Bold”.
    I appreciate so much any help from you.
    Best regards,
    Nabil

    Here is another version of my package ORDExcelSB. It includes almost all the formatting needs in Excel.
    Package Specification:_
    CREATE OR REPLACE PACKAGE ORDExcelSB AS
      /* Saubhik: These constants are added */
        BorderEdgeLeft CONSTANT BINARY_INTEGER:= 7;
        BorderEdgeTop CONSTANT BINARY_INTEGER:=8;
        BorderEdgeBottom CONSTANT BINARY_INTEGER:=9;
        BorderEdgeRight CONSTANT BINARY_INTEGER:=10;
        BorderInsideVertical CONSTANT BINARY_INTEGER:=11;
        BorderInsideHorizontal CONSTANT BINARY_INTEGER:=12;
      /* Declare externally callable subprograms. */
      /* Start: These functions are newly aded by Saubhik Banerjee */
      FUNCTION CreateExcelApplication(servername VARCHAR2) RETURN binary_integer;
      FUNCTION OpenExcelFile(filename VARCHAR2, sheetname VARCHAR2)
        RETURN binary_integer;
      FUNCTION SetCellColor(range varchar2, style INTEGER)
        return binary_integer;
      FUNCTION SetCellBorder(range varchar2, BordersIndex BINARY_INTEGER, BorderStyle BINARY_INTEGER)
        return binary_integer;   
      FUNCTION FormatFontStyle(range varchar2, fontstyle varchar2)
        return binary_integer;   
      FUNCTION FormatFontColor(range varchar2, fontcolor INTEGER)
        return binary_integer;   
      FUNCTION FormatFontName(range varchar2, fontname varchar2)
        return binary_integer;  
      FUNCTION FormatFontSize(range varchar2, fontsize INTEGER)
        return binary_integer ;  
      /* End: These functions are newly aded by Saubhik Banerjee */
      FUNCTION CreateExcelWorkSheet(servername varchar2) return binary_integer;
      FUNCTION InsertData(range varchar2, data binary_integer, type varchar2)
        return binary_integer;
      FUNCTION InsertDataReal(range varchar2,
                              data  double precision,
                              type  varchar2) return binary_integer;
      FUNCTION GetDataNum(range varchar2) return binary_integer;
      FUNCTION GetDataStr(range varchar2) return varchar2;
      FUNCTION GetDataReal(range varchar2) return double precision;
      FUNCTION GetDataDate(range varchar2) return date;
      FUNCTION InsertData(range varchar2, data varchar2, type varchar2)
        return binary_integer;
      FUNCTION InsertData(range varchar2, data Date, type varchar2)
        return binary_integer;
      FUNCTION InsertChart(xpos   binary_integer,
                           ypos   binary_integer,
                           width  binary_integer,
                           height binary_integer,
                           range  varchar2,
                           type   varchar2) return binary_integer;
      FUNCTION SaveExcelFile(filename varchar2) return binary_integer;
      FUNCTION ExitExcel return binary_integer;
    END ORDExcelSB;
    Package Body:_
    CREATE OR REPLACE PACKAGE BODY ORDExcelSB AS
      DummyToken        binary_integer;
      applicationToken  binary_integer := -1;
      WorkBooksToken    binary_integer := -1;
      WorkBookToken     binary_integer := -1;
      WorkSheetToken    binary_integer := -1;
      WorkSheetToken1   binary_integer := -1;
      RangeToken        binary_integer := -1;
      ChartObjectToken  binary_integer := -1;
      ChartObject1      binary_integer := -1;
      Chart1Token       binary_integer := -1;
      i                 binary_integer;
      retNum            binary_integer;
      retReal           double precision;
      retStr            varchar2(255);
      retDate           DATE;
      error_src         varchar2(255);
      error_description varchar2(255);
      error_helpfile    varchar2(255);
      error_helpID      binary_integer;
      FUNCTION CreateExcelApplication(servername VARCHAR2) RETURN binary_integer IS
      BEGIN
        dbms_output.put_line('Creating Excel application...');
        i := OrdCOM.CreateObject('Excel.Application',
                                 0,
                                 servername,
                                 applicationToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking Workbooks...');
        i := ORDCOM.GetProperty(applicationToken,
                                'WorkBooks',
                                0,
                                WorkBooksToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        RETURN i;
      END CreateExcelApplication;
      FUNCTION OpenExcelFile(filename VARCHAR2, sheetname VARCHAR2)
        RETURN binary_integer IS
      BEGIN
        dbms_output.put_line('Opening Excel file ' || filename || ' ...');
        ORDCOM.InitArg();
        ORDCOM.SetArg(filename, 'BSTR');
        i := ORDCOM.Invoke(WorkBooksToken, 'Open', 1, DummyToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Opening WorkBook');
        i := ORDCOM.GetProperty(applicationToken,
                                'ActiveWorkbook',
                                0,
                                WorkBookToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking WorkSheets..');
        i := ORDCOM.GetProperty(applicationToken,
                                'WorkSheets',
                                0,
                                WorkSheetToken1);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking WorkSheet');
        ORDCOM.InitArg();
        ORDCOM.SetArg(sheetname, 'BSTR');
        i := ORDCOM.GetProperty(WorkBookToken, 'Sheets', 1, WorkSheetToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Opened ');
        RETURN i;
      END OpenExcelFile;
      * Invoke the Excel Automation Server and create a Workbook object as
      * well as a worksheet object
      FUNCTION CreateExcelWorkSheet(servername varchar2) return binary_integer IS
      BEGIN
        dbms_output.put_line('Creating Excel application...');
        i := ORDCOM.CreateObject('Excel.Application',
                                 0,
                                 servername,
                                 applicationToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking Workbooks...');
        /*i:=ORDCOM.Invoke(applicationToken, 'WorkBooks',0, WorkBooksToken);*/
        i := ORDCOM.GetProperty(applicationToken,
                                'WorkBooks',
                                0,
                                WorkBooksToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking Add to WorkBooks...');
        ORDCOM.InitArg();
        ORDCOM.SetArg(-4167, 'I4');
        i := ORDCOM.Invoke(WorkBooksToken, 'Add', 1, WorkBookToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking WorkSheets..');
        ORDCOM.InitArg();
        ORDCOM.SetArg('Sheet 1', 'BSTR');
        /*  i:=ORDCOM.Invoke(applicationToken, 'WorkSheets', 1, WorkSheetToken);*/
        i := ORDCOM.GetProperty(applicationToken,
                                'WorkSheets',
                                0,
                                WorkSheetToken1);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.Invoke(WorkSheetToken1, 'Add', 0, WorkSheetToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        return i;
      END CreateExcelWorkSheet;
      * Invoke the Range method to obtain a range token. Then set the property value
      * at the specified range to the data required
      FUNCTION InsertData(range varchar2, data binary_integer, type varchar2)
        RETURN binary_integer IS
      BEGIN
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.SetProperty(RangeToken, 'Value', data, type);
        IF (i = 0) THEN
          i := ORDCOM.SetProperty(RangeToken, 'ColumnWidth', 15, 'I2');
        END IF;
        i := ORDCOM.DestroyObject(RangeToken);
        RETURN i;
      END InsertData;
    /* Saubhik: This function is added to set the cell Border */
      FUNCTION SetCellBorder(range varchar2, BordersIndex BINARY_INTEGER, BorderStyle BINARY_INTEGER)
        return binary_integer IS
        --fontToken binary_integer;
        BorderToken BINARY_INTEGER;
       BEGIN
           ORDCOM.InitArg();
          ORDCOM.SetArg(range, 'BSTR');
          i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
          ORDCOM.InitArg();
          ORDCOM.SetArg(BordersIndex, 'I2');
          i := ORDCOM.GetProperty(RangeToken, 'Borders', 1, BorderToken);
          i := ORDCOM.SetProperty(BorderToken, 'weight', BorderStyle, 'I2');
          i := ORDCOM.DestroyObject(BorderToken);
          i := ORDCOM.DestroyObject(RangeToken);
          return i;
        END SetCellBorder; 
    /* Saubhik: This function is added to set the cell background color */
      FUNCTION SetCellColor(range varchar2, style INTEGER)
        return binary_integer IS
        --fontToken binary_integer;
        DummyToken BINARY_INTEGER;
        SelectionToken BINARY_INTEGER;
        InteriorToken BINARY_INTEGER;
        --applicationToken
          BEGIN
          ORDCOM.InitArg();
          ORDCOM.SetArg(range, 'BSTR');
          i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
          i := ORDCOM.Invoke(RangeToken,'SELECT',0,DummyToken);
          i := ORDCOM.GetProperty(applicationToken,'Selection',0,SelectionToken);
          i := ORDCOM.GetProperty(SelectionToken, 'Interior', 0, InteriorToken);
          i := ORDCOM.SetProperty(InteriorToken, 'ColorIndex', style, 'I2');
          i := ORDCOM.DestroyObject(RangeToken);
          return i;
        END SetCellColor;
    /* Saubhik: This function is added to change the font style like Bold, Italic etc. */
      FUNCTION FormatFontStyle(range varchar2, fontstyle varchar2)
        return binary_integer IS
        fontToken binary_integer;
          BEGIN
          ORDCOM.InitArg();
          ORDCOM.SetArg(range, 'BSTR');
          i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
          i := ORDCOM.GetProperty(RangeToken, 'Font', 0, FontToken);
          IF fontstyle = 'Bold' OR fontstyle = 'Italic' OR
             fontstyle = 'Underline' THEN
              i := ORDCOM.SetProperty(FontToken, fontstyle, True, 'BOOL');
          END IF;
          i := ORDCOM.DestroyObject(FontToken);
          i := ORDCOM.DestroyObject(RangeToken);
          return i;
        END FormatFontStyle;
    /* Saubhik: This function is added to change the font style like Arial, Bookman, Century etc. */
      FUNCTION FormatFontName(range varchar2, fontname varchar2)
        return binary_integer IS
        fontToken binary_integer;
          BEGIN
          ORDCOM.InitArg();
          ORDCOM.SetArg(range, 'BSTR');
          i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
          i := ORDCOM.GetProperty(RangeToken, 'Font', 0, FontToken);
          i := ORDCOM.SetProperty(FontToken, 'Name', fontname, 'BSTR');
          i := ORDCOM.DestroyObject(FontToken);
          i := ORDCOM.DestroyObject(RangeToken);
          return i;
        END FormatFontName;   
      /* Saubhik: This function is added to change the font style like Arial, Bookman, Century etc. */
      FUNCTION FormatFontSize(range varchar2, fontsize INTEGER)
        return binary_integer IS
        fontToken binary_integer;
          BEGIN
          ORDCOM.InitArg();
          ORDCOM.SetArg(range, 'BSTR');
          i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
          i := ORDCOM.GetProperty(RangeToken, 'Font', 0, FontToken);
          i := ORDCOM.SetProperty(FontToken, 'Size', fontsize, 'I2');
          i := ORDCOM.DestroyObject(FontToken);
          i := ORDCOM.DestroyObject(RangeToken);
          return i;
        END FormatFontSize;   
    /* Saubhik: This function is added to change the font color like Black, Blue etc. */
      FUNCTION FormatFontColor(range varchar2, fontcolor INTEGER)
        return binary_integer IS
        fontToken binary_integer;
          BEGIN
          ORDCOM.InitArg();
          ORDCOM.SetArg(range, 'BSTR');
          i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
          i := ORDCOM.GetProperty(RangeToken, 'Font', 0, FontToken);
              i := ORDCOM.SetProperty(FontToken, 'ColorIndex', fontcolor, 'I2');
          i := ORDCOM.DestroyObject(FontToken);
          i := ORDCOM.DestroyObject(RangeToken);
          return i;
        END FormatFontColor;
      * Invoke the Range method to obtain a range token. Then set the property value
      * at the specified range to the data required
      FUNCTION GetDataNum(range varchar2) RETURN binary_integer IS
      BEGIN
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.GetProperty(RangeToken, 'Value', 0, retNum);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.DestroyObject(RangeToken);
        RETURN retNum;
      END GetDataNum;
      FUNCTION GetDataReal(range varchar2) RETURN double precision IS
      BEGIN
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.GetProperty(RangeToken, 'Value', 0, retReal);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.DestroyObject(RangeToken);
        RETURN retReal;
      END GetDataReal;
      FUNCTION GetDataStr(range varchar2) RETURN varchar2 IS
      BEGIN
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.GetProperty(RangeToken, 'Value', 0, retStr);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.DestroyObject(RangeToken);
        RETURN retStr;
      END GetDataStr;
      FUNCTION GetDataDate(range varchar2) RETURN Date IS
      BEGIN
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.GetProperty(RangeToken, 'Value', 0, retDate);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.DestroyObject(RangeToken);
        RETURN retDate;
      END GetDataDate;
      FUNCTION InsertData(range varchar2, data DATE, type varchar2)
        RETURN binary_integer IS
      BEGIN
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        i := ORDCOM.SetProperty(RangeToken, 'Value', data, type);
        i := ORDCOM.DestroyObject(RangeToken);
        RETURN i;
      END InsertData;
      FUNCTION InsertDataReal(range varchar2,
                              data  double precision,
                              type  varchar2) RETURN binary_integer IS
      BEGIN
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        i := ORDCOM.SetProperty(RangeToken, 'Value', data, type);
        i := ORDCOM.DestroyObject(RangeToken);
        RETURN i;
      END InsertDataReal;
      FUNCTION InsertData(range varchar2, data varchar2, type varchar2)
        RETURN binary_integer IS
      BEGIN
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        i := ORDCOM.SetProperty(RangeToken, 'Value', data, type);
        i := ORDCOM.DestroyObject(RangeToken);
        RETURN i;
      END InsertData;
      * Insert a chart at the x and y position of the spreadsheet with the desired
      * height and width. Then also uses the ChartWizard to draw the graph with data
      * in a specified range area with a specified charting type.
      FUNCTION InsertChart(xpos   binary_integer,
                           ypos   binary_integer,
                           width  binary_integer,
                           height binary_integer,
                           range  varchar2,
                           type   varchar2) RETURN binary_integer IS
        charttype binary_integer := -4099;
      BEGIN
        ORDCOM.InitArg();
        i := ORDCOM.GetProperty(WorkSheetToken,
                                'ChartObjects',
                                0,
                                ChartObjectToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        ORDCOM.InitArg();
        ORDCOM.SetArg(xpos, 'I2');
        ORDCOM.SetArg(ypos, 'I2');
        ORDCOM.SetArg(width, 'I2');
        ORDCOM.SetArg(height, 'I2');
        i := ORDCOM.Invoke(ChartObjectToken, 'Add', 4, ChartObject1);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.GetProperty(ChartObject1, 'Chart', 0, Chart1Token);
        ORDCOM.InitArg();
        ORDCOM.SetArg(range, 'BSTR');
        i := ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
        ORDCOM.InitArg();
        ORDCOM.SetArg(RangeToken, 'DISPATCH');
        IF type = 'xlPie' THEN
          charttype := -4102;
        ELSIF type = 'xl3DBar' THEN
          charttype := -4099;
        ELSIF type = 'xlBar' THEN
          charttype := 2;
        ELSIF type = 'xl3dLine' THEN
          charttype := -4101;
        END IF;
        ORDCOM.SetArg(charttype, 'I4');
        i := ORDCOM.Invoke(Chart1Token, 'ChartWizard', 2, DummyToken);
        i := ORDCOM.DestroyObject(RangeToken);
        i := ORDCOM.DestroyObject(ChartObjectToken);
        i := ORDCOM.DestroyObject(ChartObject1);
        i := ORDCOM.DestroyObject(Chart1Token);
        RETURN i;
      END InsertChart;
      * Save the Excel File. WARNING: Do not specify a filename that already exist
      * since there is no graphical context, Oracle would not be able to pop
      * out a warning message for existing file. This causes Excel to hang
      FUNCTION SaveExcelFile(filename varchar2) return binary_integer IS
      BEGIN
        dbms_output.put_line('Saving Excel file...');
        ORDCOM.InitArg();
        ORDCOM.SetArg(filename, 'BSTR');
        i := ORDCOM.Invoke(WorkBookToken, 'SaveAs', 1, DummyToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        RETURN i;
      END SaveExcelFile;
      * Close the Excel spreadsheet and exit from it
      FUNCTION ExitExcel return binary_integer is
      BEGIN
        dbms_output.put_line('Closing workbook and quitting...');
        ORDCOM.InitArg();
        ORDCOM.InitArg();
        ORDCOM.SetArg(FALSE, 'BOOL');
        dbms_output.put_line('Closing workbook...');
        i := ORDCOM.Invoke(WorkBookToken, 'Close', 0, DummyToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.DestroyObject(WorkBookToken);
        ORDCOM.InitArg();
        dbms_output.put_line('Closing workbooks...');
        i := ORDCOM.Invoke(WorkBooksToken, 'Close', 0, DummyToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.DestroyObject(WorkBooksToken);
        i := ORDCOM.Invoke(applicationToken, 'Quit', 0, DummyToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        i := ORDCOM.DestroyObject(WorkSheetToken);
        i := ORDCOM.DestroyObject(WorkSheetToken1);
        i := ORDCOM.DestroyObject(applicationToken);
        i := ORDCOM.DestroyObject(ChartObjectToken);
        i := ORDCOM.DestroyObject(Chart1Token);
        i := ORDCOM.DestroyObject(ChartObject1);
        i := ORDCOM.DestroyObject(dummyToken);
        RETURN i;
      END ExitExcel;
    END ORDExcelSB;

  • Import from Excel to Oracle table

    I have couple questions.
    is the 20K Excel file upload limit still apply???
    I want to use APEX to upload data from Excel to Oracle, some data manipulation will be needed in the process.
    This will be a utility that will be used by users not DBAs or Developers.
    It would great if someone has an example application.
    or do you think I should use different tool???
    Thanks

    What are the steps for importing using the SQL
    developer?Steps are (assuming you have already installed XE und schema where data should be imported):
    1. Install SQL Developer
    2. Start SQL Developer
    3. Log on into desired schema
    4. Open Dialog Box "Excel Import Data"
    5. Specify file to import with options
    6. Click on OK
    7. Check in Navigator imported data's
    Done ;-)

  • Oracle COM Automation Excel Charts

    Hi All
    I read and manged to get all the COM Demos working from the COM Automation Feature Developer's Guide <http://www.oracle.com/pls/db102/to_toc?pathname=win.102%2Fb14310%2Ftoc.htm&remark=portal+%28Windows%29>.
    I have changed the Excel Demo to match what I want to use in my Database. Everything works great except the Excel Chart portion. I what to have Chart Type line but when I use xlLine, the chart still produces a bar chart.
    Does anyone know how to produce a Line Chart in Excel using Oracle COM Automation?
    I am using Windows Server 2003, Office Standard Edition 2003, and Oracle 10.2
    My modified sql is
    <pre>
    set serveroutput on;
    declare
    CURSOR c1 IS     
         SELECT time, flow
         FROM RT_FLOW_TEST
         WHERE time > to_date('31-dec-2006','dd-mon-yyyy')
         ORDER BY time;
    error_message varchar2(1200);
    n binary_integer:=2;
    i binary_integer;
    filename varchar2(255);
    cellIndex varchar2(40);
    cellValue varchar2(40);
    cellColumn varchar2(10);
    returnedTime varchar2(20);
    currencyvalue double precision;
    datevalue DATE;
    looptext varchar2(20);
    error_src varchar2(255);
    error_description varchar2(255);
    error_helpfile varchar2(255);
    error_helpID binary_integer;
    begin
    filename:='c:\reports\2007\overnight\meadowlandsflow';
    i:=ORDExcel.CreateExcelWorkSheet('');
    i:=ORDExcel.InsertData('A1', 'Day', 'BSTR');
    i:=ORDExcel.InsertData('B1', 'Flow', 'BSTR');
    For c1_rec IN c1 LOOP
    cellColumn:=TO_CHAR(n);
    cellIndex:=CONCAT('A',cellColumn);
    dateValue:=c1_rec.time;
    i:=ORDExcel.InsertData(cellIndex, dateValue, 'DATE');
    cellIndex:=CONCAT('B',cellColumn);
    cellValue:=c1_rec.flow;
    i:=ORDExcel.InsertData(cellIndex, cellValue, 'BSTR');
    n:=n+1;
    END LOOP;
    i:=ORDExcel.InsertChart(100,10,400,400,'Sheet2!$B$2:$B$365,Sheet2!$A$2:$A$365','xlLine');
    select TO_CHAR(SYSDATE, 'DD-MON-YYYY') into returnedTime from dual;
    filename:=CONCAT(filename, returnedTime);
    i:=ORDExcel.SaveExcelFile(filename);
    i:=ORDExcel.ExitExcel();
    end;
    </pre>
    Any help is much appreciated.
    Cheers
    Brad

    Hi Saubhik ,
    i saw that thread, but my question was that is there any limitation that the in order to use Oracle COM Automation should the OS on which oracle database is installed has to be Windows only.
    or can it be implement in oracle database installed in Linux OS also ?
    Edited by: krishna_36 on May 9, 2011 4:38 AM

  • Map excel columns to oracle table column using forms 6i

    Hello,
    I am importing data from excel to oracle table using oracle forms 6i.
    Suppose my table have 3 columns id, name,sal. The excel sheet i am importing having
    3 or more colums, also excel sheet columns are not in order as per table columns.
    i.e my table have id, name, sal
    and excel have name, sal, id
    my question is how can i map excel colums with table colums and insert it into table.
    I am using oracle 6i forms (ole2 package).
    Thanks

    What was wrong with the first answer to the same question?
    Re: map excel columns on oracle forms and insert it into database

  • Data From Excel to Oracle

    Hi, how can I do a Stored Procedure or free code to import data from Excel to Oracle Table? Tanks for all.

    I never use UTL_FILE. I use Delphi and I need to make a subrotine to import xls file to oracle. So, I prefer to do into DataBase, using database resource, but I do not oracle expertise, I have some difficulties. Tanks.

  • Pivot Report in Excel from Oracle data base

    I need to bring data in Excel from Oracle table.
    The connectivity was established without any problem.
    When trying to transform the newly created query into
    a pivot table a am not able to see the data inside the
    "Data area" of pivot table as it is in the data base
    tables, instead Excel transforms the data in Sum, Average,
    etc...
    I believe it is an Excel issue but I am not sure.
    Any sugestions would be appreciated.
    Thanks,
    Larry Moise

    Thank u but already i do have apache POI
    hoew to make a conversion of coulmn data to excel

  • Importing excel data into oracle tables

    Hello gurus,
    Importing excel data into oracle tables..
    I know this is the most common question on the thread ...First, i searched the forum, i found bunch of threads with loading data using sqlloader, converting excel into .Txt, tab delimited file, .csv file etc....
    Finally i was totally confused in terms how to get this done....
    Here is wat i have
       - Excel file on local computer.
       - i have laod data into dev environment tables(So no risk involved, but want to try something simple)
       - Oracle version 11.1.0.7
       - Sqlplus and toad (editors)
    Here is wat i like to do ....i dont know if its possible
        - Without going to unix server can i do everthing on local system by making use of oracle db and sqlplus or toad
       SQLLOADER might be one option...but i dont want to go the unix server for placing files and logs and stuff.
    Wat will be best and simplest option to do?? and wat format will best to convert from excel into csv, or txt or tab delimited etc.....
    If you suggest sqlloader, any code example will be greatly appriciated.
    Thank you so much!!!

    Hi,
    user642297 wrote:
    Imran,
    This is increadible option in toad!!! It works absolutely sweet!! I have toad 9.7 version. IT works great. Thank you so much!!You are welcome :)
    Well i have further discussion on this ....this option is great if you doing in staging or development area. What if your doing in prod?? If you automating the sqlloader then how do u do it?? I think we still need to stick with traditional approach of laoding data by making use of SQLLoader right ?? If m wrong please correct me.well, in our case, we do have access to a custom schema in prod where we create the staging table and load the data from datafiles.
    try this:
    load data
    infile 'C:\dest.csv'
    into table dest_table
    fields terminated by "~" optionally enclosed by '"'
    TRAILING NULLCOLS
    (name,
    owner_nm,
    description_column,
    UPDT_DT DATE 'MM/DD/YYYY')
    {code}
    you can get more info about sql loader and your error here:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96652/ch05.htm
    http://www.allinterview.com/showanswers/53766.html
    And one more quick question ...i found an example of control file , in that i see .dat format file. Is it a data file ?? can i try that option ?? But in excel i didnt see to convert the .dat format file.
    Any thoughts ???
    It is same as a delimiter text file.
    steps to create a .dat file (from a excel file):
    1. Insert a column between two columns and populate it with the delimiter (in our case, it is ~)
    2. Save the file as unicode text.
    3. Open the file in text editor and remove all the tabs (find an replace with blank)
    4. Save the file as "DEST.dat". Select encoding as UTF-8 while saving.
    5. Your .dat file is ready.
    Regards
    Imran
    Edited by: Imran Soudagar on Apr 22, 2010 10:22 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Open an Excel file to read and load it into Oracle - Oracle COM Automation

    Hello All,
    Please I need your help for this problem:
    I need to load Excel sheet data (read the data) and load it into Oracle database (insert into a table), the excel file created and has data before, and saved with xls format. and I need to do that using the Oracle® COM Automation (ordcom package). The examples I found open and create a new workbook and deletes the old saved data, so I need to open (edit) the sheet just for reading.
    I appreciate ans sample code to help me do that, Please help me out. This is very urgent.
    Thanks alot and best regards,
    Nabil

    For reading from Excel, there are some easy ways like Oracle Heterogenious Services. If you want to use COM then:
    My orawpcom.dll file exists in the directory C:\oracle\product\10.2.0\db_2\bin
    C:\oracle\product\10.2.0\db_2\bin>dir orawpco*.dll
    Volume in drive C is C_Drive
    Volume Serial Number is 8A93-1441
    Directory of C:\oracle\product\10.2.0\db_2\bin
    03/20/2006  05:06 PM            61,440 orawpcom.dll
    10/11/2006  03:20 PM            81,920 orawpcom10.dll
                   2 File(s)        143,360 bytes
                   0 Dir(s)  65,407,717,376 bytes free
    C:\oracle\product\10.2.0\db_2\bin>Information about my database version.
    SQL> /* My databaser version */
    SQL> SELECT * FROM v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    SQL> Preparing the user SCOTT for COM automation.
    Now, I will run comwrap.sql from scott user. I have edited the comwrap.sql to adjust my library path here:
    create library utils_lib as 'C:\oracle\product\10.2.0\db_3\bin\orawpcom.dll';Running comwrap.sql and ExcelSolution.sql .....
    SQL> conn scott@orclsb
    Enter password: *****
    Connected.
    SQL> @c:\comwrap.sql
    drop library utils_lib
    ERROR at line 1:
    ORA-04043: object UTILS_LIB does not exist
    Library created.
    drop package ORDCOM
    ERROR at line 1:
    ORA-04043: object ORDCOM does not exist
    drop TYPE OAArgTable
    ERROR at line 1:
    ORA-04043: object OAARGTABLE does not exist
    Type created.
    drop TYPE OAArgTypeTable
    ERROR at line 1:
    ORA-04043: object OAARGTYPETABLE does not exist
    Type created.
    drop function OAgetNumber
    ERROR at line 1:
    ORA-04043: object OAGETNUMBER does not exist
    Function created.
    drop function OAgetStr
    ERROR at line 1:
    ORA-04043: object OAGETSTR does not exist
    Function created.
    drop function OAgetBool
    ERROR at line 1:
    ORA-04043: object OAGETBOOL does not exist
    Function created.
    drop function OAsetNumber
    ERROR at line 1:
    ORA-04043: object OASETNUMBER does not exist
    Function created.
    drop function OAsetString
    ERROR at line 1:
    ORA-04043: object OASETSTRING does not exist
    Function created.
    drop function OAsetBoolean
    ERROR at line 1:
    ORA-04043: object OASETBOOLEAN does not exist
    Function created.
    drop function OAInvokeDouble
    ERROR at line 1:
    ORA-04043: object OAINVOKEDOUBLE does not exist
    Function created.
    drop function OAInvokeBoolean
    ERROR at line 1:
    ORA-04043: object OAINVOKEBOOLEAN does not exist
    Function created.
    drop function OAInvokeString
    ERROR at line 1:
    ORA-04043: object OAINVOKESTRING does not exist
    Function created.
    drop function OACreate
    ERROR at line 1:
    ORA-04043: object OACREATE does not exist
    Function created.
    drop function OADestroy
    ERROR at line 1:
    ORA-04043: object OADESTROY does not exist
    Function created.
    drop function OAGetLastError
    ERROR at line 1:
    ORA-04043: object OAGETLASTERROR does not exist
    Function created.
    drop function OAQueryMethods
    ERROR at line 1:
    ORA-04043: object OAQUERYMETHODS does not exist
    Function created.
    Package created.
    Package body created.
    SQL>
    SQL> @c:\ExcelSolution.sql
    drop package ORDExcel
    ERROR at line 1:
    ORA-04043: object ORDEXCEL does not exist
    Package created.
    Package body created.
    SQL>
    I have modified ORDExcel a little bit and renamed it as ORDExcelSB. You need this version for reading the excel.
    SQL> @C:\ExcelSolutionSB.sql
    Package dropped.
    Package created.
    Package body created.
    SQL> The actual code of ORDExcelSB (ExcelSolutionSB.sql) Is:
    set serveroutput on;
    drop package ORDExcelSB;
    CREATE PACKAGE ORDExcelSB AS
       /* Declare externally callable subprograms. */
       FUNCTION CreateExcelApplication(servername VARCHAR2) RETURN binary_integer;
       FUNCTION OpenExcelFile(filename VARCHAR2, sheetname VARCHAR2) RETURN binary_integer;
       FUNCTION CreateExcelWorkSheet(servername varchar2) return binary_integer;
       FUNCTION InsertData(range varchar2, data binary_integer, type varchar2) return binary_integer;
       FUNCTION InsertDataReal(range varchar2, data double precision, type varchar2) return binary_integer;
       FUNCTION GetDataNum(range varchar2) return binary_integer;
       FUNCTION GetDataStr(range varchar2) return varchar2;
       FUNCTION GetDataReal(range varchar2) return double precision;
       FUNCTION GetDataDate(range varchar2) return date;
       FUNCTION InsertData(range varchar2, data varchar2, type varchar2) return binary_integer;
       FUNCTION InsertData(range varchar2, data Date, type varchar2) return binary_integer;
       FUNCTION InsertChart(xpos binary_integer, ypos binary_integer, width binary_integer,
                                  height binary_integer, range varchar2, type varchar2) return binary_integer;
       FUNCTION SaveExcelFile(filename varchar2) return binary_integer;
       FUNCTION ExitExcel return binary_integer;
    END ORDExcelSB;
    CREATE PACKAGE BODY ORDExcelSB AS
       DummyToken          binary_integer;     
       applicationToken binary_integer:=-1;
       WorkBooksToken     binary_integer:=-1;
       WorkBookToken     binary_integer:=-1;
       WorkSheetToken     binary_integer:=-1;
       WorkSheetToken1     binary_integer:=-1;
       RangeToken          binary_integer:=-1;
       ChartObjectToken     binary_integer:=-1;
       ChartObject1          binary_integer:=-1;
       Chart1Token          binary_integer:=-1;
       i                    binary_integer;
       retNum               binary_integer;
       retReal               double precision;
       retStr               varchar2(255);
       retDate               DATE;
    error_src varchar2(255);
    error_description varchar2(255);
    error_helpfile varchar2(255);
    error_helpID binary_integer;
    FUNCTION CreateExcelApplication(servername VARCHAR2) RETURN binary_integer IS
      BEGIN
        dbms_output.put_line('Creating Excel application...');
        i := OrdCOM.CreateObject('Excel.Application',
                                 0,
                                 servername,
                                 applicationToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking Workbooks...');
        i := ORDCOM.GetProperty(applicationToken,
                                'WorkBooks',
                                0,
                                WorkBooksToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        RETURN i;
      END CreateExcelApplication;
      FUNCTION OpenExcelFile(filename VARCHAR2, sheetname VARCHAR2)
        RETURN binary_integer IS
      BEGIN
        dbms_output.put_line('Opening Excel file ' || filename || ' ...');
        ORDCOM.InitArg();
        ORDCOM.SetArg(filename, 'BSTR');
        i := ORDCOM.Invoke(WorkBooksToken, 'Open', 1, DummyToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Opening WorkBook');
        i := ORDCOM.GetProperty(applicationToken,
                                'ActiveWorkbook',
                                0,
                                WorkBookToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking WorkSheets..');
        i := ORDCOM.GetProperty(applicationToken,
                                'WorkSheets',
                                0,
                                WorkSheetToken1);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Invoking WorkSheet');
        ORDCOM.InitArg();
        ORDCOM.SetArg(sheetname, 'BSTR');
        i := ORDCOM.GetProperty(WorkBookToken, 'Sheets', 1, WorkSheetToken);
        IF (i != 0) THEN
          ORDCOM.GetLastError(error_src,
                              error_description,
                              error_helpfile,
                              error_helpID);
          dbms_output.put_line(error_src);
          dbms_output.put_line(error_description);
          dbms_output.put_line(error_helpfile);
        END IF;
        dbms_output.put_line('Opened ');
        RETURN i;
      END OpenExcelFile;
    * Invoke the Excel Automation Server and create a Workbook object as
    * well as a worksheet object
    FUNCTION CreateExcelWorkSheet(servername varchar2) return binary_integer IS
    BEGIN
         dbms_output.put_line('Creating Excel application...');
         i:=ORDCOM.CreateObject('Excel.Application', 0, servername,applicationToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         dbms_output.put_line('Invoking Workbooks...');
         /*i:=ORDCOM.Invoke(applicationToken, 'WorkBooks',0, WorkBooksToken);*/
         i:=ORDCOM.GetProperty(applicationToken, 'WorkBooks', 0, WorkBooksToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         dbms_output.put_line('Invoking Add to WorkBooks...');
         ORDCOM.InitArg();
         ORDCOM.SetArg(-4167,'I4');
         i:=ORDCOM.Invoke(WorkBooksToken, 'Add', 1, WorkBookToken);
    IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         dbms_output.put_line('Invoking WorkSheets..');
         ORDCOM.InitArg();
         ORDCOM.SetArg('Sheet 1','BSTR');
    /*     i:=ORDCOM.Invoke(applicationToken, 'WorkSheets', 1, WorkSheetToken);*/
    i:=ORDCOM.GetProperty(applicationToken, 'WorkSheets', 0, WorkSheetToken1);
    IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
    i:=ORDCOM.Invoke(WorkSheetToken1, 'Add', 0, WorkSheetToken);
    IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         return i;
    END CreateExcelWorkSheet;
    * Invoke the Range method to obtain a range token. Then set the property value
    * at the specified range to the data required
    FUNCTION InsertData( range varchar2,
                             data binary_integer,
                             type varchar2)
                             RETURN binary_integer IS
    BEGIN
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
         IF (i=0) THEN
               i:=ORDCOM.SetProperty(RangeToken, 'ColumnWidth', 15, 'I2');
         END IF;
         i:=ORDCOM.DestroyObject(RangeToken);
         RETURN i;
    END InsertData;
    * Invoke the Range method to obtain a range token. Then set the property value
    * at the specified range to the data required
    FUNCTION GetDataNum( range varchar2)
                             RETURN binary_integer IS
    BEGIN
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retNum);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.DestroyObject(RangeToken);
         RETURN retNum;
    END GetDataNum;
    FUNCTION GetDataReal( range varchar2)
                             RETURN double precision IS
    BEGIN
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retReal);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.DestroyObject(RangeToken);
         RETURN retReal;
    END GetDataReal;
    FUNCTION GetDataStr( range varchar2)
                             RETURN varchar2 IS
    BEGIN
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retStr);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.DestroyObject(RangeToken);
         RETURN retStr;
    END GetDataStr;
    FUNCTION GetDataDate( range varchar2)
                             RETURN Date IS
    BEGIN
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retDate);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.DestroyObject(RangeToken);
         RETURN retDate;
    END GetDataDate;
    FUNCTION InsertData( range varchar2,
                             data DATE,
                             type varchar2)
                             RETURN binary_integer IS
    BEGIN
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
         i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
         i:=ORDCOM.DestroyObject(RangeToken);
         RETURN i;
    END InsertData;
    FUNCTION InsertDataReal( range varchar2,
                             data double precision,
                             type varchar2)
                             RETURN binary_integer IS
    BEGIN
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
         i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
         i:=ORDCOM.DestroyObject(RangeToken);
         RETURN i;
    END InsertDataReal;
    FUNCTION InsertData( range varchar2,
                             data varchar2,
                             type varchar2)
                             RETURN binary_integer IS
    BEGIN
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
         i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
         i:=ORDCOM.DestroyObject(RangeToken);
         RETURN i;
    END InsertData;
    * Insert a chart at the x and y position of the spreadsheet with the desired
    * height and width. Then also uses the ChartWizard to draw the graph with data
    * in a specified range area with a specified charting type.
    FUNCTION InsertChart(xpos binary_integer, ypos binary_integer,
                              width binary_integer, height binary_integer,
                              range varchar2, type varchar2) RETURN binary_integer IS
         charttype binary_integer:= -4099;
    BEGIN
         ORDCOM.InitArg();
         i:=ORDCOM.GetProperty(WorkSheetToken, 'ChartObjects', 0, ChartObjectToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         ORDCOM.InitArg();
         ORDCOM.SetArg(xpos,'I2');
         ORDCOM.SetArg(ypos,'I2');
         ORDCOM.SetArg(width,'I2');
         ORDCOM.SetArg(height,'I2');
         i:=ORDCOM.Invoke(ChartObjectToken, 'Add', 4, ChartObject1);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.GetProperty(ChartObject1, 'Chart', 0,Chart1Token);
         ORDCOM.InitArg();
         ORDCOM.SetArg(range, 'BSTR');
         i:=ORDCOM.GetProperty(WorkSheetToken,'Range', 1, RangeToken);
         ORDCOM.InitArg();
         ORDCOM.SetArg(RangeToken, 'DISPATCH');
         IF type='xlPie' THEN
              charttype := -4102;
         ELSIF type='xl3DBar' THEN
              charttype := -4099;
         ELSIF type='xlBar' THEN
              charttype := 2;
         ELSIF type='xl3dLine' THEN
              charttype:= -4101;
         END IF;
         ORDCOM.SetArg(charttype,'I4');
         i:=ORDCOM.Invoke(Chart1Token,'ChartWizard', 2, DummyToken);
         i:=ORDCOM.DestroyObject(RangeToken);
         i:=ORDCOM.DestroyObject(ChartObjectToken);
         i:=ORDCOM.DestroyObject(ChartObject1);
         i:=ORDCOM.DestroyObject(Chart1Token);
         RETURN i;
    END InsertChart;
    * Save the Excel File. WARNING: Do not specify a filename that already exist
    * since there is no graphical context, Oracle would not be able to pop
    * out a warning message for existing file. This causes Excel to hang
    FUNCTION SaveExcelFile(filename varchar2) return binary_integer IS
    BEGIN
         dbms_output.put_line('Saving Excel file...');
         ORDCOM.InitArg();
         ORDCOM.SetArg(filename,'BSTR');
         i:=ORDCOM.Invoke(WorkBookToken, 'SaveAs', 1, DummyToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         RETURN i;     
    END SaveExcelFile;
    * Close the Excel spreadsheet and exit from it
    FUNCTION ExitExcel return binary_integer is
    BEGIN
         dbms_output.put_line('Closing workbook and quitting...');
         ORDCOM.InitArg();
         ORDCOM.InitArg();
         ORDCOM.SetArg(FALSE,'BOOL');
         dbms_output.put_line('Closing workbook...');
         i:=ORDCOM.Invoke(WorkBookToken, 'Close', 0, DummyToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.DestroyObject(WorkBookToken);     
         ORDCOM.InitArg();
         dbms_output.put_line('Closing workbooks...');
         i:=ORDCOM.Invoke(WorkBooksToken, 'Close', 0, DummyToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.DestroyObject(WorkBooksToken);
         i:=ORDCOM.Invoke(applicationToken, 'Quit', 0, DummyToken);
         IF (i!=0) THEN
         ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
         dbms_output.put_line(error_src);
         dbms_output.put_line(error_description);
         dbms_output.put_line(error_helpfile);
         END IF;
         i:=ORDCOM.DestroyObject(WorkSheetToken);     
         i:=ORDCOM.DestroyObject(WorkSheetToken1);     
         i:=ORDCOM.DestroyObject(applicationToken);
         i:=ORDCOM.DestroyObject(ChartObjectToken);
         i:=ORDCOM.DestroyObject(Chart1Token);
         i:=ORDCOM.DestroyObject(ChartObject1);
         i:=ORDCOM.DestroyObject(dummyToken);
         RETURN i;
    END ExitExcel;
    END ORDExcelSB;
    /I have created an excel named as C:\Example.xls.
    Name     SlNo     Job     Dept     Salary     Bonus
    Saubhik Banerjee     706090     IT Specialist     GBS     100     10
    Partha S Mohanty     706091     Pogrmmer     APPS     70     20
    Partha Sarkar     889300     Condultant     FIN     200     30
    Useless     98009     PM     PM     900     90
    SQL> SET SERVEROUT ON
    SQL> DECLARE
      2 
      3    v_Name          varchar2(90);
      4    v_SlNo          varchar2(100);
      5    v_Job           varchar2(200);
      6    v_Dept          varchar2(100);
      7    v_recon_remark  varchar2(50);
      8    v_sal_amt_usd   number;
      9    v_Bonus_amt_usd number;
    10 
    11    result INTEGER;
    12 
    13    i        binary_integer;
    14    filename varchar2(255);
    15 
    16  BEGIN
    17 
    18    filename := 'C:\Example.xls';
    19 
    20    result := ORDExcelSB.CreateExcelApplication('');
    21    result := ORDExcelSB.OpenExcelFile(filename, 'Sheet1');
    22 
    23    /* Excluding the header row and reading the first 5 row */
    24    FOR n in 2 .. 5 LOOP
    25   
    26      v_Name          := ORDExcelSB.GetDataStr('A' || n);
    27      v_SlNo          := ORDExcelSB.GetDataReal('B' || n);
    28      v_Job           := ORDExcelSB.GetDataStr('C' || n);
    29      v_Dept          := ORDExcelSB.GetDataStr('D' || n);
    30      v_sal_amt_usd   := ORDExcelSB.GetDataNum('E' || n);
    31      v_Bonus_amt_usd := ORDExcelSB.GetDataNum('F' || n);
    32   
    33      dbms_output.put_line(v_Name || '  ' || v_SlNo || '  ' || v_Job || '  ' ||
    34                           v_Dept || '  ' || v_sal_amt_usd || '  ' ||
    35                           v_Bonus_amt_usd);
    36   
    37    END LOOP;
    38 
    39    result := ORDExcelSB.ExitExcel();
    40  EXCEPTION
    41    WHEN OTHERS THEN
    42      result := ORDExcelSB.ExitExcel();
    43      RAISE;
    44  END;
    45  /
    Creating Excel application...
    Invoking Workbooks...
    Opening Excel file C:\Example.xls ...
    Opening WorkBook
    Invoking WorkSheets..
    Invoking WorkSheet
    Opened
    Saubhik Banerjee  706090  IT Specialist  GBS  100  10
    Partha S Mohanty  706091  Pogrmmer  APPS  70  20
    Partha Sarkar  889300  Condultant  FIN  200  30
    Useless  98009  PM  PM  900  90
    Closing workbook and quitting...
    Closing workbook...
    Closing workbooks...
    PL/SQL procedure successfully completed.
    SQL> Although, You haven't asked, but you can use this code to write to excel file (.xls)
    DECLARE
    CURSOR c1 IS     
         SELECT empno, ename, dname, sal, hiredate
         FROM emp e, dept d
         WHERE e.deptno = d.deptno;
    error_message varchar2(1200);
    n binary_integer:=2;
    i binary_integer;
    filename varchar2(255);
    cellIndex varchar2(40);
    cellValue varchar2(40);
    cellColumn varchar2(10);
    returnedTime varchar2(20);
    currencyvalue double precision;
    datevalue DATE;
    empno binary_integer;
    looptext varchar2(20);
    error_src varchar2(255);
    error_description varchar2(255);
    error_helpfile varchar2(255);
    error_helpID binary_integer;
    begin
    filename:='c:\example2.xls';
    i:=ORDExcel.CreateExcelWorkSheet('');
    i:=ORDExcel.InsertData('A1', 'EmpNo', 'BSTR');
    i:=ORDExcel.InsertData('B1', 'Name', 'BSTR');
    i:=ORDExcel.InsertData('C1', 'Dept', 'BSTR');
    i:=ORDExcel.InsertData('D1', 'Salary', 'BSTR');
    i:=ORDExcel.InsertData('E1', 'HireDate', 'BSTR');
    For c1_rec IN c1 LOOP
    cellColumn:=TO_CHAR(n);
    cellIndex:=CONCAT('A',cellColumn);
    cellValue:=TO_CHAR(c1_rec.empno);
    empno:=cellValue;
    i:=ORDExcel.InsertData(cellIndex, empno, 'I2');
    cellIndex:=CONCAT('B',cellColumn);
    cellValue:=c1_rec.ename;
    i:=ORDExcel.InsertData(cellIndex, cellValue, 'BSTR');
    cellIndex:=CONCAT('C',cellColumn);
    cellValue:=c1_rec.dname;
    i:=ORDExcel.InsertData(cellIndex, cellValue, 'BSTR');
    cellIndex:=CONCAT('D',cellColumn);
    cellValue:=c1_rec.sal;
    currencyValue:=cellValue;
    i:=ORDExcel.InsertData(cellIndex, currencyValue, 'CY');
    cellIndex:=CONCAT('E',cellColumn);
    dateValue:=c1_rec.hiredate;
    i:=ORDExcel.InsertData(cellIndex, dateValue, 'DATE');
    n:=n+1;
    END LOOP;
    i:=ORDExcel.SaveExcelFile(filename);
    i:=ORDExcel.ExitExcel();
    EXCEPTION
    WHEN OTHERS THEN
      i:=ORDExcel.ExitExcel();
      RAISE;
    END;

  • 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  to load the data from excel  file  into table in oracle using UTL_FI

    How to load the data from excel file into table in oracle
    and from table to excel file
    using UTL_FILE package
    Please give me some example

    This is something i tried in oracle apex
    http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
    Regards,
    CKLP

  • Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    I also Tried to Use This
    But How can i Use SQLLDR Command In Stored Procedure.
    Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
    So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure.

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

Maybe you are looking for

  • Customizing Requisition request in HCM Processes & Forms

    Hi HCMers, We have just upgraded our development system to EhP4 in ECC and E-Recruiting systems, and SP5 in E-recruiting. We want to use the simple requisition request process in HCM Processes and Forms but have several customizations to apply. For e

  • Macbook Pro and 80 inch Sharp TV.

    Has anyone connected a Macbook Pro to an 80 inch Sharp TV? I am planning on getting that TV. It's the new 80LC875U. I tried connecting to a new Sony TV but the TV supposedly has a low resolution pc input. The image was not clear and it was very pixil

  • 6.1.2 update and "no service"

    I've always struggled with "no service" on iPhones but since I got my iPhone 5 it's been near perfect, always had signal even in places I couldn't normally get a signal - that is, until I updated to 6.1.2. I'm kicking myself and am so frustrated. Sin

  • Tracks in nwdi

    Hi, there are tracks in nwdi and need to do mofification if requriement and want to  deploy the trackinto new server from old server? how to deploy the tracks in new server from old server?

  • Exception while loading an Applet

    I am getting the attached exception when trying to access a page containing an applet. The same page displays fine when tried from a different machine Java Plug-in 1.5.0_11 Using JRE version 1.5.0_11 Java HotSpot(TM) Client VM User home directory = C