Read file into a table

Is there a way of reading content of a file into a table? what if that file is overwritten each x minutes for update?

yes sure.
JSplitPane's can hold two components - so your table can be one of the components, and some other feature e.g. a JPanel (which is containing other components in turn) is the other component.
e.g.
JSplitPane mainSplitPane_LeftRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); // or JSplitPane.VERTICAL_SPLIT
mainSplitPane_LeftRight.setOneTouchExpandable(true); // set whether you want to be able to maximize one of the components in the JSplitPane using a button on the divider
// component 1 of splitpane
JTable yourTable = new JTable(); // initialise with your code here
// component 2 of splitpane
JTree tree = new JTree(); // example component
yourTable.setMinimumSize(new Dimension(10, 10)); // this ensures we can always move the dividers
tree.setMinimumSize(new Dimension(10, 10)); // this ensures we can always move the dividers
// add the components
mainSplitPane_LeftRight.setLeftComponent(yourTable);
mainSplitPane_LeftRight.setRightComponent(tree);
// then now we have a populated JSplitPane which you may wanna shove into a JFrame??
JFrame frame = new JFrame("Tester");
frame.getContentPane().add(mainSplitPane_LeftRight);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show(); // show it.Hope that helped.

Similar Messages

  • Question about reading csv file into internal table

    Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
    I would like to ask how can I read a CSV file into internal table from files in application server?
    I can't simply use SPLIT as there may be comma in the content. e.g.
    "abc","aaa,ab",10,"bbc"
    My expected output:
    abc
    aaa,ab
    10
    bbb
    Thanks again for your help.

    Hi Gundam,
    Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
    OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
    DO.
    READ DATASET dsn INTO record.
      PERFORM parser USING record.
    ENDDO.
    *DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
    *DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
    *DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
    FORM parser USING str.
    DATA field(12).
    DATA field1(12).
    DATA field2(12).
    DATA field3(12).
    DATA field4(12).
    DATA cnt TYPE i.
    DATA len TYPE i.
    DATA temp TYPE i.
    DATA start TYPE i.
    DATA quote TYPE i.
    DATA rec_cnt TYPE i.
    len = strlen( str ).
    cnt = 0.
    temp = 0.
    rec_cnt = 0.
    DO.
    *  Start at the beginning
      IF start EQ 0.
        "string just ENDED start new one.
        start = 1.
        quote = 0.
        CLEAR field.
      ENDIF.
      IF str+cnt(1) EQ '"'.  "Check for qoutes
        "CHECK IF quotes is already set
        IF quote = 1.
          "Already quotes set
          "Start new field
          start = 0.
          quote = 0.
          CONCATENATE field '"' INTO field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            CONDENSE field.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
    *      WRITE field.
        ELSE.
          "This is the start of quotes
          quote = 1.
        ENDIF.
      ENDIF.
      IF str+cnt(1) EQ ','. "Check end of field
        IF quote EQ 0. "This is not inside quote end of field
          start = 0.
          quote = 0.
          CONDENSE field.
    *      WRITE field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      CONCATENATE field str+cnt(1) INTO field.
      cnt = cnt + 1.
      IF cnt GE len.
        EXIT.
      ENDIF.
    ENDDO.
    WRITE: field1, field2, field3, field4.
    ENDFORM.
    Regards,
    Wenceslaus.

  • How to import data from a text file into a table

    Hello,
    I need help with importing data from a .csv file with comma delimiter into a table.
    I've been struggling to figure out how to use the "Import from Files" wizard in Oracle 10g web-base Enterprise Manager.
    I have not been able to find a simple instruction on how to use the Wizard.
    I have looked at the Oracle Database Utilities - Overview of Oracle Data Pump and the Help on the "Import: Files" page.
    Neither one gave me enough instruction to be able to do the import successfully.
    Using the "Import from file" wizard, I created a Directory Object using the Create Directory Object button. I Copied the file from which i needed to import the data into the Operating System Directory i had defined in the Create Directory Object page. I chose "Entire files" for the Import type.
    Step 1 of 4 is the "Import:Re-Mapping" page, I have no idea what i need to do on this page. All i know i am not tying to import data that was in one schema into a different schema and I am not importing data that was in one tablespace into a different tablespace and i am not R-Mapping datafiles either. I am importing data from a csv file.
    For step 2 of 4, "Import:Options" page, I selected the same directory object i had created.
    For step 3 of 4, I entered a job name and a description and selected Start Immediately option.
    What i noticed going through the wizard, the wizard never asked into which table do i want to import the data.
    I submitted the job and I got ORA-31619 invalid dump file error.
    I was sure that the wizard was going to fail when it never asked me into which table do i want to import the data.
    I tried to use the "imp" utility in command-line window.
    After I entered (imp), i was prompted for the username and the password and then the buffer size as soon as i entered the min buffer size I got the following error and the import was terminated:
    C:\>imp
    Import: Release 10.1.0.2.0 - Production on Fri Jul 9 12:56:11 2004
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Username: user1
    Password:
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
    tion
    With the Partitioning, OLAP and Data Mining options
    Import file: EXPDAT.DMP > c:\securParms\securParms.csv
    Enter insert buffer size (minimum is 8192) 30720> 8192
    IMP-00037: Character set marker unknown
    IMP-00000: Import terminated unsuccessfully
    Please show me the easiest way to import a text file into a table. How complex could it be to do a simple import into a table using a text file?
    We are testing our application against both an Oracle database and a MSSQLServer 2000 database.
    I was able to import the data into a table in MSSQLServer database and I can say that anybody with no experience could easily do an export/import in MSSQLServer 2000.
    I appreciate if someone could show me how to the import from a file into a table!
    Thanks,
    Mitra

    >
    I can say that anybody with
    no experience could easily do an export/import in
    MSSQLServer 2000.
    Anybody with no experience should not mess up my Oracle Databases !

  • How to load a XML file into a table using PL/SQL

    Hi Guru,
    I have a requirement, that i have to create a procedure or a package in PL/SQL to load  XML file into a table.
    How we can achive this.

    ODI_NewUser wrote:
    Hi Guru,
    I have a requirement, that i have to create a procedure or a package in PL/SQL to load  XML file into a table.
    How we can achive this.
    Not a perfectly framed question. How do you want to load the XML file? Hoping you want to parse the xml file and load it into a table you can do this.
    This is the xml file
    karthick% cat emp_details.xml
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <EMPNO>7782</EMPNO>
      <ENAME>CLARK</ENAME>
      <JOB>MANAGER</JOB>
      <MGR>7839</MGR>
      <HIREDATE>09-JUN-1981</HIREDATE>
      <SAL>2450</SAL>
      <COM>0</COM>
      <DEPTNO>10</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7839</EMPNO>
      <ENAME>KING</ENAME>
      <JOB>PRESIDENT</JOB>
      <HIREDATE>17-NOV-1981</HIREDATE>
      <SAL>5000</SAL>
      <COM>0</COM>
      <DEPTNO>10</DEPTNO>
    </ROW>
    </ROWSET>
    You can write a query like this.
    SQL> select *
      2    from xmltable
      3         (
      4            '/ROWSET/ROW'  passing xmltype
      5            (
      6                 bfilename('SDAARBORDIRLOG', 'emp_details.xml')
      7               , nls_charset_id('AL32UTF8')
      8            )
      9            columns empno    number      path 'EMPNO'
    10                  , ename    varchar2(6) path 'ENAME'
    11                  , job      varchar2(9) path 'JOB'
    12                  , mgr      number      path 'MGR'
    13                  , hiredate varchar2(20)path 'HIREDATE'
    14                  , sal      number      path 'SAL'
    15                  , com      number      path 'COM'
    16                  , deptno   number      path 'DEPTNO'
    17         );
         EMPNO ENAME  JOB              MGR HIREDATE                    SAL        COM     DEPTNO
          7782 CLARK  MANAGER         7839 09-JUN-1981                2450          0         10
          7839 KING   PRESIDENT            17-NOV-1981                5000          0         10
    SQL>

  • How to load a XML file into a table

    Hi,
    I've been working on Oracle for many years but for the first time I was asked to load a XML file into a table.
    As an example, I've found this on the web, but it doesn't work
    Can someone tell me why? I hoped this example could help me.
    the file acct.xml is this:
    <?xml version="1.0"?>
    <ACCOUNT_HEADER_ACK>
    <HEADER>
    <STATUS_CODE>100</STATUS_CODE>
    <STATUS_REMARKS>check</STATUS_REMARKS>
    </HEADER>
    <DETAILS>
    <DETAIL>
    <SEGMENT_NUMBER>2</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>3</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic administration</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>4</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic finance</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>5</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic logistics</REMARKS>
    </DETAIL>
    </DETAILS>
    <HEADER>
    <STATUS_CODE>500</STATUS_CODE>
    <STATUS_REMARKS>process exception</STATUS_REMARKS>
    </HEADER>
    <DETAILS>
    <DETAIL>
    <SEGMENT_NUMBER>20</SEGMENT_NUMBER>
    <REMARKS> base polytechnic</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>30</SEGMENT_NUMBER>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>40</SEGMENT_NUMBER>
    <REMARKS> base polytechnic finance</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>50</SEGMENT_NUMBER>
    <REMARKS> base polytechnic logistics</REMARKS>
    </DETAIL>
    </DETAILS>
    </ACCOUNT_HEADER_ACK>
    For the two tags HEADER and DETAILS I have the table:
    create table xxrp_acct_details(
    status_code number,
    status_remarks varchar2(100),
    segment_number number,
    remarks varchar2(100)
    before I've created a
    create directory test_dir as 'c:\esterno'; -- where I have my acct.xml
    and after, can you give me a script for loading data by using XMLTABLE?
    I've tried this but it doesn't work:
    DECLARE
    acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
    BEGIN
    insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
      passing acct_doc as "d",
              x1.header_no as "hn"
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    END;
    This should allow me to get something like this:
    select * from xxrp_acct_details;
    Statuscode status remarks segement remarks
    100 check 2 rp polytechnic
    100 check 3 rp polytechnic administration
    100 check 4 rp polytechnic finance
    100 check 5 rp polytechnic logistics
    500 process exception 20 base polytechnic
    500 process exception 30
    500 process exception 40 base polytechnic finance
    500 process exception 50 base polytechnic logistics
    but I get:
    Error report:
    ORA-06550: line 19, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
    ORA-06550: line 4, column 2:
    PL/SQL: SQL Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    and if I try to change the script without using the column HEADER_NO to keep track of the header rank inside the document:
    DECLARE
    acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
    BEGIN
    insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '/ACCOUNT_HEADER_ACK/DETAILS'
      passing acct_doc
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    END;
    I get this message:
    Error report:
    ORA-19114: error during parsing the XQuery expression: 
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'SYS.DBMS_XQUERYINT' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-06512: at line 4
    19114. 00000 -  "error during parsing the XQuery expression: %s"
    *Cause:    An error occurred during the parsing of the XQuery expression.
    *Action:   Check the detailed error message for the possible causes.
    My oracle version is 10gR2 Express Edition
    I do need a script for loading xml files into a table as soon as possible, Give me please a simple example for understanding and that works on 10gR2 Express Edition
    Thanks in advance!

    The reason your first SQL statement
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
      passing acct_doc as "d",
              x1.header_no as "hn"
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    returns the error you noticed
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
    is because Oracle is expecting XML to be passed in.  At the moment I forget if it requires a certain format or not, but it is simply expecting the value to be wrapped in simple XML.
    Your query actually runs as is on 11.1 as Oracle changed how that functionality worked when 11.1 was released.  Your query runs slowly, but it does run.
    As you are dealing with groups, is there any way the input XML can be modified to be like
    <ACCOUNT_HEADER_ACK>
    <ACCOUNT_GROUP>
    <HEADER>....</HEADER>
    <DETAILS>....</DETAILS>
    </ACCOUNT_GROUP>
      <ACCOUNT_GROUP>
      <HEADER>....</HEADER>
      <DETAILS>....</DETAILS>
      </ACCOUNT_GROUP>
    </ACCOUNT_HEADER_ACK>
    so that it is easier to associate a HEADER/DETAILS combination?  If so, it would make parsing the XML much easier.
    Assuming the answer is no, here is one hack to accomplish your goal
    select x1.status_code,
            x1.status_remarks,
            x3.segment_number,
            x3.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS'
      passing acct_doc as "d",
      columns detail_no      for ordinality,
              detail_xml     xmltype       path 'DETAIL'
    ) x2,
    xmltable(
      'DETAIL'
      passing x2.detail_xml
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS') x3
    WHERE x1.header_no = x2.detail_no;
    This follows the approach you started with.  Table x1 creates a row for each HEADER node and table x2 creates a row for each DETAILS node.  It assumes there is always a one and only one association between the two.  I use table x3, which is joined to x2, to parse the many DETAIL nodes.  The WHERE clause then joins each header row to the corresponding details row and produces the eight rows you are seeking.
    There is another approach that I know of, and that would be using XQuery within the XMLTable.  It should require using only one XMLTable but I would have to spend some time coming up with that solution and I can't recall whether restrictions exist in 10gR2 Express Edition compared to what can run in 10.2 Enterprise Edition for XQuery.

  • How to get data of tabulated text file into internal table

    hi all,
    i want to get data from tabulated text file(notepad) into internal table. i searched in SCN and got lot of post regarding  how to convert excel file into internal table but i didnt get posts regarding text file.
    thanks
    SAchin

    try:
    DATA: BEGIN OF tabulator,
            x(1) TYPE x VALUE '09',
          END OF tabulator.
      READ DATASET file INTO wa.
    split wa at tabulator into table itab.
    A.

  • Loading XML file into DB Table

    Hi
    I m quite new to the loading XML file into database table.
    It will be great if anyone could guide me to through.
    Now,
    i have an XML file which has to be loaded into the DB table.
    what are the steps involved in doing this. How do i go from here ??
    your help is greatly appriciated ???
    Thank you so much!!
    -Shashi

    OK - Although you really should read the XMLDB FAQ on this forum, here is some sample code of ONE of the ways of doing it
    (there are multiple ways - and this is not the most simple one)
    Based on Oracle 11gR1
    -- sqlplus /nolog
    clear screen
    set termout on
    set feed on
    set lines 40
    set long 10000000
    set serveroutput on
    set lines 100
    set echo on
    connect / as sysdba
    col filename for a80
    col xml      for a80
    -- Create schema “OTN”
    drop user OTN cascade;
    purge dba_recyclebin;
    create user OTN identified by OTN;
    grant dba, xdbadmin to OTN;
    EXECUTE dbms_java.grant_permission( 'OTN', 'java.io.FilePermission','G:\OTN\xmlstore','read' );
    prompt pause
    pause
    clear screen
    -- Create directory
    connect OTN/OTN;
    show user
    drop directory OTN_USE_CASE;
    CREATE directory OTN_USE_CASE AS 'G:\OTN\xmlstore';
    SELECT extract((XMLTYPE(bfilename('OTN_USE_CASE','ABANDA-20030407215829881GMT.xml'),NLS_CHARSET_ID('AL32UTF8'))),'*') AS "XML"
    from   dual;
    prompt pause
    pause
    clear screen
    -- Directory Listing - Tom Kyte
    create global temporary table DIR_LIST
    ( filename varchar2(255) )
    on commit delete rows
    create or replace
      and compile java source named "DirList"
    as
    import java.io.*;
    import java.sql.*;
    public class DirList
    {public static void getList(String directory)
                       throws SQLException
    {   File path = new File( directory );
        String[] list = path.list();
        String element;
        for(int i = 0; i < list.length; i++)
        {   element = list;
    #sql { INSERT INTO DIR_LIST (FILENAME)
    VALUES (:element) };
    create or replace procedure get_dir_list( p_directory in varchar2 )
    as language java
    name 'DirList.getList( java.lang.String )';
    prompt pause
    pause
    clear screen
    -- The content of the global temporary table
    exec get_dir_list( 'G:\OTN\xmlstore' );
    select * from dir_list;
    -- "COMMIT" will clear / truncate the global temporary table...
    prompt pause
    pause
    clear screen
    -- Combined: Reading XML content from multiple XML files
    commit;
    exec get_dir_list( 'G:\OTN\xmlstore' );
    select * from dir_list where filename like '%.xml'
    and rownum <= 10;
    prompt pause
    pause
    clear screen
    select extract((XMLTYPE(bfilename('OTN_USE_CASE',dl.filename),NLS_CHARSET_ID('AL32UTF8'))),'*') AS "XML"
    from dir_list dl
    where dl.filename like '%.xml' and rownum <= 2;
    prompt pause
    pause
    clear screen
    -- If you can select it you can insert it...
    -- drop table OTN_xml_store purge;
    create table OTN_xml_store of xmltype
    xmltype store as binary xml
    commit;
    exec get_dir_list( 'G:\OTN\xmlstore' );
    set time on timing on
    insert into OTN_xml_store
    select XMLTYPE(bfilename('OTN_USE_CASE',dl.filename),NLS_CHARSET_ID('AL32UTF8')) AS "XML"
    from dir_list dl
    where dl.filename like '%.xml';
    set time off timing off
    commit;
    select count(*) from OTN_xml_store;
    prompt pause
    pause
    clear screen
    -- If you can select it you can create resources and files
    set time on timing on
    commit;
    exec get_dir_list( 'G:\OTN\xmlstore' );
    select count(*) from dir_list where filename like '%.xml';
    set serveroutput on size 10000
    DECLARE
    XMLdoc XMLType;
    res BOOLEAN;
    v_foldername varchar2(4000) := '/public/OTN/';
    cursor c1
    is
    select dl.filename FNAME
    , XMLTYPE(bfilename('OTN_USE_CASE',dl.filename),NLS_CHARSET_ID('AL32UTF8')) XMLCONTENT
    from dir_list dl
    where dl.filename like '%.xml'
    and rownum <= 100;
    BEGIN
    -- Create XDB repository Folder
    if (dbms_xdb.existsResource(v_foldername))
    then
    dbms_xdb.deleteResource(v_foldername,dbms_xdb.DELETE_RECURSIVE_FORCE);
    end if;
    res:=DBMS_XDB.createFolder(v_foldername);
    -- Create XML files in the XDB Repository
    for r1 in c1
    loop
    if (DBMS_XDB.CREATERESOURCE(v_foldername||r1.fname, r1.xmlcontent))
    then
    dbms_output.put_line(v_foldername||r1.fname);
    null;
    else
    dbms_output.put_line('Loop Exception :'||sqlerrm);
    end if;
    end loop;
    EXCEPTION WHEN OTHERS THEN
    dbms_output.put_line('Others Exception: '||sqlerrm);
    END;
    set time off timing off
    commit;
    prompt pause
    pause
    clear screen
    -- FTP and HTTP
    clear screen
    prompt
    prompt *** FTP - Demo ***
    prompt
    prompt pause
    pause
    host ftp
    -- open localhost 2100
    -- user OTN OTN
    -- cd public
    -- cd OTN
    -- ls
    -- bye
    clear screen
    prompt
    prompt *** Microsoft Internet Explorer - Demo ***
    prompt
    prompt pause
    pause
    host "C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://OTN:OTN@localhost:8080/public/OTN/
    prompt pause
    pause
    -- Accessing the XDB Repository content via Resource View
    -- Selecting content from a resource via XBDUriType
    clear screen
    prompt set long 300
    set long 300
    prompt Relative Path - (path)
    SELECT path(1) as filename
    FROM RESOURCE_VIEW
    WHERE under_path(RES, '/public/OTN', 1) = 1
    and rownum <= 10
    prompt pause
    pause
    clear screen
    prompt Absolute Path - (any_path)
    select xdburitype(any_path).getClob() as xml
    FROM RESOURCE_VIEW
    WHERE under_path(RES, '/public/OTN', 1) = 1
    and rownum <= 1;
    prompt pause
    pause
    -- CLEANUP ENVIRONMENT
    clear screen
    prompt
    prompt >>>>> Clean UP !!! <<<<<<
    prompt
    prompt Cleanup environment and drop user...!!!
    prompt
    pause
    clear screen
    conn / as sysdba
    alter session set current_schema=OTN;
    begin
    dbms_xdb.deleteResource('/public/OTN',dbms_xdb.DELETE_RECURSIVE_FORCE);
    commit;
    end;
    alter session set current_schema=sys;
    drop user OTN cascade;
    Based on http://www.liberidu.com/blog/?p=1053

  • How to insert a gif file into a table?

    Hi,
    I need to insert a gif file into a table. Can anyone tell me where I can find the information on how to create this kind of table, how to insert a gif file into a table and how to select?
    Thanks,
    Helen

    Hi Helen,
    You could read about that in the documentation which is available online.
    For a starter: BLOB. And I bet there are many examples to be found on the web.
    Good luck. :)
    Regards,
    Guido

  • Upload .txt file into Database Table

    Hi,
    I was wondering if someone could please point me in the right direction. I've been looking around the forum but can't find anything to help me achieve the following.
    I would like to be able to upload a .txt file using a webpage. Then store the information inside this file into database tables.
    eg. contents of mytextfile.txt:
    richard
    10 anywhere street, anytown, somewhere
    111 222 333 444
    joe
    9 somestreet, elsewhere
    999 888 777 666
    peter
    214 nearby lane, overhere
    555 555 555 555
    I would like to insert this data into a table.
    eg. table name = CONTACTS
    userid = primary key (using sequence)
    username = (line 1 - richard, joe, peter)
    address = (line 2)
    phone_no = (line 3)
    As you can see the records will appear 1 at a time and will have a blank line between records. Is there anyway for me to upload a file like this and have it placed into tables?
    I have seen http://otn.oracle.com/products/database/htmldb/howtos/howto_file_upload.html but this seems to be for uploading a whole file and downloading the same file, rather than extracting data from the file.
    I hope I have managed to explain my problem.
    Many thanks,
    Richard.

    Richard,
    HTML DB allows you to upload CSV files via the Data Workshop. That data would then be parsed and inserted into a specific table. Alternatively, if you have your data in an Excel spreadsheet, and it is less than 32k, you can copy & paste the data directly into HTML DB's Data Workshop, which will then parse and import it into the Oracle database.
    The one obstacle you may have to overcome is converting your data from the format you outlined to CSV format. Specifically, you would have to make this:
    richard
    10 anywhere street, anytown, somewhere
    111 222 333 444
    Look something like this:
    "richard","10 anywhere street, anytown, somewhere","111 222 333 444"
    Hope this helps,
    - Scott -

  • Uploading the contents of file into  custom table

    Hi ,
    I have a req where in i want to put the contents of the file into the Z table . I have taken a file upload UI element and in that i have taken 4 attributes as file name f, file type ,file size and file contents and binded this file contents to the data property of the UI element. Now with out explicitly defining the fields i want to put all this content of file into the Z table created  for any file created or if i could put the whole text file into that table so that any one could see that file even though its not saved in the desktop for that user.
    Can any one help me out?

    Yes i am converting it inot the lstring using the same FM which you have given. I have to store the total file but the only doubt is like if its a input field how could i save a file form. Can you please check the code i want to save the total file into the table.
    DATA lo_nd_upload TYPE REF TO if_wd_context_node.
        DATA lo_el_upload TYPE REF TO if_wd_context_element.
        data  i_data TYPE STANDARD TABLE OF string.
        DATA ls_upload TYPE wd_this->Element_upload.
        data lv_field type string.
        data lt_file type TABLE OF ZFILE_UPLOAD.
        data ls_file LIKE LINE OF lt_file.
        data l_xstring type xstring.
       data  fields TYPE string_table.
    data l_String type string.
      navigate from <CONTEXT> to <UPLOAD> via lead selection
        lo_nd_upload = wd_context->get_child_node( name = wd_this->wdctx_upload ).
      @TODO handle non existant child
      IF lo_nd_upload IS INITIAL.
      ENDIF.
      get element via lead selection
        lo_el_upload = lo_nd_upload->get_element( ).
      @TODO handle not set lead selection
        IF lo_el_upload IS INITIAL.
        ENDIF.
      get all declared attributes
        lo_el_upload->get_static_attributes(
          IMPORTING
            static_attributes = ls_upload ).
       DATA lv_file_contents TYPE wd_this->Element_upload-file_contents.
    navigate from <CONTEXT> to <UPLOAD> via lead selection
    @TODO handle non existant child
    IF lo_nd_upload IS INITIAL.
    ENDIF.
    get element via lead selection
       lo_el_upload = lo_nd_upload->get_element( ).
    alternative access  via index
    lo_el_upload = lo_nd_upload->get_element( index = 1 ).
    @TODO handle not set lead selection
       IF lo_el_upload IS INITIAL.
       ENDIF.
    get single attribute
       lo_el_upload->get_attribute(
         EXPORTING
           name =  'FILE_CONTENTS'
         IMPORTING
           value = l_xstring ).
    for text file conversion we have to FM
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
      EXPORTING
      FROM_CODEPAGE       = '8500'
        IN_XSTRING          = l_xstring
      OUT_LEN             =
    IMPORTING
       OUT_STRING          = l_string.
    SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
      LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
        read TABLE fields into lv_field index 1.
    endloop.
    ls_upload will contain all the file details
    ls_file-file_size = xstrlen( ls_upload-file_contents ) * lv_float  .
    ls_file-file_name = ls_upload-file_name.
    ls_file-file_type = ls_upload-file_type.
    ls_file-file_contents = ls_upload-file_contents.
    insert ZFILE_UPLOAD FROM ls_file.
    thanks

  • Uploading CSV file into internal table

    Hi,
    I want to upload a CSV file into internal table.The flat file is having values as below:
    'AAAAA','2003-10-11 07:52:37','167','Argentina',NULL,NULL,NULL,NULL,NULL,'MX1',NULL,NULL,'AAAA BBBB',NULL,NULL,NULL,'1',NULL,NULL,'AR ',NULL,NULL,NULL,'ARGENT','M1V','MX1',NULL,NULL,'F','F','F','F','F',NULL,'1',NULL,'MX','MMI ',NULL
    'jklhg','2004-06-25 08:01:57','456','hjllajsdk','MANAGUA   ',NULL,NULL,'265-5139','266-5136 al 38','MX1',NULL,NULL,'hjgkid GRÖBER','sdfsdf dfs asdfsdf 380 ad ased,','200 as ads, sfd sfd abajao y 50 m al sdf',NULL,'1',NULL,NULL,'NI ',NULL,NULL,NULL,'sdfdfg','M1V','dds',NULL,NULL,
    Here I can not even split at ',' because some of the values are having value like NULL and some have values with comma too,
    The delimiter is a quote and the separator is a comma here.
    Can anyone help on this?
    Thanks.
    Edited by: Ginger on Jun 29, 2009 9:08 AM

    As long as there can be a comma in a text literal you are right that the spilt command doesn't help. However there is one possibility how to attack this under one assumption:
    - A comma outside a text delimiter is always considered a separator
    - A comma inside a text delimiter is always considered a comma as part of the text
    You have to read you file line by line and then travel along the line string character by character and setting a flag or counter for the text delimiters:
    e.g.
    "Text","Text1, Text2",NULL,NULL,"Text"
    String Index  1: EQ " => lv_delimiter = 'X'
    String Index  2: EQ T => text literal (because lv_delimiter = 'X')
    String Index  3: EQ e => text literal (because lv_delimiter = 'X')
    String Index  4: EQ x => text literal (because lv_delimiter = 'X')
    String Index  5: EQ t => text literal (because lv_delimiter = 'X')
    String Index  6: EQ " => lv_delimiter = ' ' (because it was 'X' before)
    String Index  7: EQ , => This is a separator because lv_delimiter = ' '
    String Index  8: EQ " => lv_delimiter = 'X' (because it was ' ' before)
    String Index  9: EQ T => text literal (because lv_delimiter = 'X')
    String Index 10: EQ e => text literal (because lv_delimiter = 'X')
    String Index 11: EQ x => text literal (because lv_delimiter = 'X')
    String Index 12: EQ t => text literal (because lv_delimiter = 'X')
    String Index 13: EQ 1 => text literal (because lv_delimiter = 'X')
    String Index 14: EQ , => text literal (because lv_delimiter = 'X')
    String Index 15: EQ T => text literal (because lv_delimiter = 'X')
    Whenever you hit a 'real' separator (lv_delimiter = ' ') you pass the value of the string before that up to the previous separator into the next structure field.
    This is not an easy way to do it, but if you might have commas in your text literal and NULL values I gues it is probably the only way to go.
    Hope that helps,
    Michael

  • Trying to put a file into a table

    hello i am trying to put a file into a table but a don't know how to do it if somebody knows how to do it please send me an example.
    thanks a lot

    Hi
    The easier way is saved the excel file in CSV format and use the fm GUI_UPLOAD to read that file:
    DATA: TAB_FILE(1000) OCCURS 0.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME = 'C:\MY_FILE.CSV'
      TABLES
        DATA_TAB = TAB_FILE.
    In TAB_FILE you'll have your file.
    If you want to create a dialog to search the file:
    parameters: p_file1 like rlgrap-filename.
    at selection-screen on value-request for p_file1.
    data: filetable type filetable,
          rc        type i.
      data wa_file like file_table.
      refresh filetable.
      call method cl_gui_frontend_services=>file_open_dialog
       EXPORTING
       WINDOW_TITLE            =
       DEFAULT_EXTENSION       =
       DEFAULT_FILENAME        =
       FILE_FILTER             =
       INITIAL_DIRECTORY       =
       MULTISELECTION          =
       WITH_ENCODING           =
        changing
          file_table              = filetable
          rc                      = rc
       USER_ACTION             =
       FILE_ENCODING           =
      exceptions
        file_open_dialog_failed = 1
        cntl_error              = 2
        error_no_gui            = 3
        not_supported_by_gui    = 4
        others                  = 5.
      if sy-subrc = 0.
        if rc = 1.
          read table filetable into wa_file index 1.
          move wa_file-filename to p_file1.
        endif.
      endif.
    start-of-selection.
    DATA: TAB_FILE(1000) OCCURS 0,
          file type string.
    move p_file1 to file.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME = file
      TABLES
        DATA_TAB = TAB_FILE.
    Max
    Message was edited by: max bianchi

  • Import an excel file into a table

    Anybody can help me on importing a big text file (i.e. an excel file) into a table without using SQL Loader?
    Thnx in advance

    user5181307 wrote:
    There is another method where in you can edit the listener file to make an entry for separate service. then create a database link and tns entry to use the service to access the Excel.What you are referring to is called Heterogeneous Services and allows Oracle to treat something as an External database.
    For Excel files you would do it like this...
    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... however, from the sounds of the original question the OP is referring to a flat file of data (like a CSV file) and not really an Excel file (.xls) which is a proprietary binary format that you won't be able to read with SQL*Loader or External Tables.
    The best method for the OP's requirements would appear to be external tables which were introduced with 9i.

  • Loading an XML file into the table without creating a directory .

    Hi,
    I wanted to load an XML file into a table column . But I should not create a directory in the server and placing the XML file there and giving the path in the insert query. Can anybody help me here?
    Thanks in advance.

    You could write a java stored procedure that retrieves the file into a clob. Wrap that in a function call and use it in your insert statement.
    This solution require read privileges granted by sys and is therefore only feasible if the top-level directory/directories are known or you get read-access to everything.

  • Inserting XML file  into a Table

    Hello,
    Can someone provide me with a sample code to load xml files into a table. Thanks a lot.
    Rajeesh

    Keeping my fingers crossed that this quote from "Building XML Oracle Applications" by Steve Muench (O'Reilly & Associates, 2000, ISBN 1-56592-691-9) falls into the "fair use" category, and that you want it in PL/SQL, here is a procedure:
    PROCEDURE insertXMLFile
    (dir VARCHAR2, file VARCHAR2, name VARCHAR2 := NULL) IS
    theBFile BFILE;
    theCLob CLOB;
    theDocName VARCHAR2(200) := NVL(name,file);
    BEGIN
    -- (1) Insert a new row into xml_documents with an empty CLOB, and
    -- (2) Retrieve the empty CLOB into a variable with RETURNING.INTO
    INSERT INTO stylesheets(docname,sheet) VALUES(theDocName,empty_clob( ))
    RETURNING sheet INTO theCLob;
    -- (3) Get a BFile handle to the external file
    theBFile := BFileName(dir,file);
    -- (4) Open the file
    dbms_lob.fileOpen(theBFile);
    -- (5) Copy the contents of the BFile into the empty CLOB
    dbms_lob.loadFromFile(dest_lob => theCLob, src_lob => theBFile, amount => dbms_lob.getLength(theBFile));
    -- (6) Close the file and commit
    dbms_lob.fileClose(theBFile);
    COMMIT;
    END;

Maybe you are looking for

  • Itune error code 4450, 4400.......a million codes!!!  HELP TOONZ....

    Dear Toonz, It seems you know more than the support team from itunes...they keep blaming my cd drive, when the drive works for everything else. Do I need Matchmusic? cause I gave it the boot. One cd burned from itunes. another says error.........then

  • Firefox draining energy fast and Safari is too slow

    Hello, I bought my macbook pro in the end of 2011 and since mavericks it's has been nothing but disappointment, I am considering buying another computer to use Linux mainly because since I am a electronic engineering student, OS X doesn't satisfies m

  • Instability in 2012 Mac Mini Server after Yosemite 10.1.1 Install

    I bought a NEW 2012 Mac Mini server on clearance in the online Apple Store last month. I had a 256 SDD installed as startup drive along with Yosemite earlier this week. It crashes, freezes and randomly restarts. Not sure where to start with trying to

  • How do I solve this problem authorizing my Kobo reader?

    When I click-on "Authorize Device" I get the following message: 'This computer is authorized without an Adobe ID' despite me having one. When I then click-on create Adobe ID it takes me to the page with my existing Adobe ID. When I enter my existing

  • Multiple Images Import template?

    Hi folks, First of all, I cannot find the link to product import templates anywhere after an hour's search. That is just wrong! Secondly, as I remember seeing one, it doesn't offer multiple views of a single product. But i've seen stores with multipl