Text file storing in a database table

I have a text file, that contains so many lines in it,..
Now the problem is that.. I want to store my text file with the pl/sql code in a database table....
plz suggest, how to create a table and how to store that text file in a database table.....

The following code is tested and get the correct result (forms 10.1.2.0):
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table tclob  (col_lob clob);
Table created.
Declare
  file  TEXT_IO.FILE_TYPE;
  text  varchar2(10000);
  L$Clob CLOB;
Begin
  -- prepare CLOB object --
  dbms_lob.createtemporary( L$Clob, TRUE ) ;
  -- open text file --
  file := TEXT_IO.FOPEN( 'c:\forms.css', 'R' ) ;
  If TEXT_IO.IS_OPEN( file) Then
    -- start reazding file --
     Begin
       Loop
         TEXT_IO.GET_LINE( file, text );
         -- add the line to the CLOB variable --
            dbms_lob.writeappend (L$Clob, length(text), text);
       End loop;
    Exception
      when no_data_found then
        -- end of text file --
        TEXT_IO.FCLOSE(file);
      when others then
       null;
    End ;
    -- store the CLOB in the database --
    --Update tclob Set col_lob = L$Clob ;
    insert into tclob (col_lob) values (L$Clob);
    forms_ddl('commit');
       dbms_lob.freetemporary( L$Clob ) ;
  End if ;
exception
     when others then
     message(error_code || '-' || error_text);
End;Francois

Similar Messages

  • How to load text file data to Oracle Database table?

    By using Oracle Forms, how to load text file data to Oracle Database table?

    Metalink note 33247.1 explains how to use text_io as suggested by Robin to read the file into a Multi-Row block. However, that article was written for forms 4.5 and uses CREATE_RECORD in a loop. There was another article, 91513.1 describing the more elegant method of 'querying' the file into the block by transactional triggers. Unfortunately this more recent article has disappeared without trace and Oracle deny its existence. I know it existed as I have a printed copy in front of me, and very useful it is too.

  • Pool data from text file and insert into database

    Can anyone tell me how to pool data from a text file and insert into database?
    let's say my text file is in this format
    123456 Peter 22
    234567 Nicholas 24
    345678 Jane 20
    Then I need to insert the all the value for this three column into a table which has the three column name ID, Name, Age
    Anyone knows? I need to do this urgently...Thank in advanced

    1. Use BufferedReader and read the file line by line.
    2. Loop thru the file and do the following steps with in this loop.
    3. Use StringTokenizer to seperate each line into three values (columns).
    4. Now create a insert statement with these values and add the statement to the batch (using addBatch() method of PreparedStatement or Statement).
    5. Finally (after exiting the loop), execute these batch of statements (using ps.executeBatch()).
    Sudha

  • How to import the data in a .xls or .xlsx file into a oracle database table

    Hi,
    Please tell me how to import the data in a .xls or .xlsx file into a oracle database table in Oracle 10gR2 using Oracle Warehouse Builder 10gR2.

    ....can we do something through Non-Oracle->ODBC?Yes, it is possible, look at this thread
    [SQLServer access from AIX Warehouse builder|http://forums.oracle.com/forums/thread.jspa?messageID=2502982]
    If your server (with target DB and OWB runtime) is on Windows OS this configuration will be simpler - you can use single server.
    And additional link on OWB blog (with 11g transparent gateway)
    [http://blogs.oracle.com/warehousebuilder/2008/01/11g_heterogeneous_agent.html]
    (configuring nonoracle connection with 10g generic connectivity very similar to 11g gateway)
    Also look at
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4406709207206#18830681837358
    Regards,
    Oleg

  • How to modify the contents of a text file stored along with a midlet

    Hi,
    I have been developing a application in j2me wherein i need to first read the contents of the text file stored along with the midlet and later erase the existing content and update it with some text.
    I was able to read the file in the following manner
    InputStream is = getClass().getResourceAsStream("myfile.txt");
    Now i need to erase the contents and then update it the new content, how do i do it. Kinldy please help me out. It is very urgent.
    Thanks

    Didn't you hear me the first time?
    http://forum.java.sun.com/thread.jspa?threadID=701360&messageID=4068435#4068435

  • Download of files stored in the database

    I am using FireFox and my users IE. Download of files stored in the database worked for me but not for my users. I recieve a choice of downloading the file or opening it with a full file name and file type. IE users have some strange behaviour - no name of the file and they can only save it to their local drive - some kind of weird microsoft security option. I was searching for it but couldn't find. Anyone here who would know where to search for it?
    Denes Kubicek

    Hello Jens,
    I am using the standard procedure from the manual:
    CREATE OR REPLACE PROCEDURE download_my_file_pr (p_file IN NUMBER)
    AS
    v_mime VARCHAR2 (255);
    v_length NUMBER;
    v_file_name VARCHAR2 (2000);
    lob_loc BLOB;
    BEGIN
    SELECT mime_type, blob_content, NAME, DBMS_LOB.getlength (blob_content)
    INTO v_mime, lob_loc, v_file_name, v_length
    FROM my_file_table
    WHERE ID = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    OWA_UTIL.mime_header (NVL (v_mime, 'application/octet'), FALSE);
    -- set the size so the browser knows how much to download
    HTP.p ('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    HTP.p ('Content-Disposition: attachment; filename="' || v_file_name || '"');
    -- close the headers
    OWA_UTIL.http_header_close;
    -- download the BLOB
    wpg_docload.download_file (lob_loc);
    END download_my_file_pr;
    Denes Kubicek

  • Best ways to view/display PDF/Excel files stored in the Database

    What are best ways to display/view PDF/Excel files stored in the Database? thanks L

    Thanks tom, sorry let me explain. Currently we have oracle forms screen, using webutil to store/view files into DB. client won't like the interface, they want us to make it more friendly, drag and drop if possible, load multiple files, as possible.. So I am exploring different ways to improve may be java (or jdev/any any other), different screen designs, different features for fileupload/download/view options.

  • Oracle reports to display PDF/Excel files stored in the Database

    can we use Oracle reports to view/display PDF/Excel files stored in the Database? Thanks Lalitha

    A document stored in the database can be easily retrieved in or via the browser using mod_plsql. Simplified:
    select content, mime_type
    into v_blob, v_mime_type
    from ...
    owa_util.mime_header(nvl(v_mimetype,'application/octet'),false);
    htp.p('Content-length: ' || dbms_lob.getlength(v_blob));
    owa_util.http_header_close;
    wpg_docload.download_file(v_blob);So, the link in your report should point to this database procedure.
    Edited by: InoL on Mar 1, 2011 4:17 PM

  • Read a text file stored in WebDynpro packages(SRc/packages)

    Hi Experts,
    I have a text file stored in the folder structure of WebDynpro Development component.
    Its stored under src>packages>com>sap>file-->data.txt
    Now i need to read data from this file and fill the context node of WD controller.
    can you guys give me an example of how to do it?
    Regards,
    Ashish Shah

    /** get file as binary */
              File file = new File(
                             WDURLGenerator.getResourcePath(
                                  wdComponentAPI.getDeployableObjectPart(),
                                  "data.txt");
              FileInputStream instream = new FileInputStream(file);
              long filelen = file.length();
              byte[] binary = new byte[(int)filelen];
              int offset = 0;
              int numread = 0;
              while(offset<binary.length &&
                        (numread = instream.read(binary,
                         offset,
                          binary.length-offset))>=0){
                   offset +=numread;
              instream.close();
              /** create Resource out of binary read */
              if(binary!=null){
                   cachedresource = WDWebResource.getWebResource(binary, WDWebResourceType.TXT);
                   url = cachedresource.getURL();
              /** create window to open document */
              IWDWindow docwin = wdComponentAPI
                                       .getWindowManager()
                                       .createNonModalExternalWindow(url, Attachment);
              docwin.show();
         }catch(Exception e){
              msgBox("error reading file");
    nikhil

  • Displaying html stored in a database table in a region

    Hi All,
    I would like to pass html to regions on the page which is stored in a database table.
    I have got this working for simple html (call a packaged function to get the html and then in a PL/SQL Anonymous Block htp.p(f_get_html(:P1_param1,'REGION1')); to display it within the region ) but what I would also like to take the html generated for charts/graphs etc out of the application and also put them into the database table so that the position on the page can be determined by database tables.(i.e. have a page with lots of regions and assign html to them at runtime). I am struggling with substituting all the necessary parameters into the HTML returned from the database and how it should be formatted.
    Any help appreciated and if I get any further I will update the post

    I have actually managed to achive this now. When I get chance I will post the code.
    The idea is that a page could have say 6 regions and depending on choices made (i.e. selected project or the individual user permissions) there are regions which you would want to display and regions you dont. Also, you may want to move regions around the page so that the important ones for that user or project etc. are at the top.
    You can then, on entering a page, query database tables to decide what is to be displayed in region1, region 2 etc. and then getting the html from the database for that region and displaying it.
    I have successfully done this now with embedded Oracle Reports showing graphs which look better than the SVG graphs and are more flexible.

  • Generate XML file from an Oracle Database Table

    Hello All,
    I want to generate a xml file from an Oracle Database table which contains a blob column.
    Can somebody give pointers on this please.
    Thanks in advance
    Sulakshana

    Use the DBMS_XMLGEN package.

  • To store text file having Multiple file formats in a database table

    Hi,
    Is it possible to store data of a text file which have different field separator between records
    Like
    palash;1111,noida
    xxxx;3333,delhi
    regards
    palash

    Hi,
    Ti load:
    1/ Declare a file with ; separator. Consider you have only to columns
    2/ Create or reverse a datastore with your 3 columns
    3/ Create an interface: file in source, table in target. For you mapping, First column is mapped on the first column of the file, second and thirth ones are parts of the second column of the file...using SQL possibilities of your target DB. For that mapping are made in the workspace.
    You have to know that you have to choice a staging area near your target schema to make those transformations.
    Regards,
    MA...different from RA.... ;o)

  • How can I make an easy *.CSV file to load into database table

    Hi All,
    I have a huge excel sheet having columns item#, description and qty. The description column sometimes maybe one word name, two word name separated with space or may be , spearated name. I want to write and PL/SQl code which will read this file and load it into database table. Now the *.CSV file is either comma delimited or tab text delmited which both do not solve my issue. Is there any better solution with anyone which can prevent the manual editing to the *.CSV file and I can easily load it to table.
    Your help is appreciated,
    Thanks
    Zahir

    SQL*Loader is probably the fastest method, but since you specifically asked for a PL/SQL method:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:464420312302

  • View pdf file stored in oracle database through oracle forms

    Forms [32 Bit] Version 10.1.2.0.2 (Production)
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    Oracle Toolkit Version 10.1.2.0.2 (Production)
    PL/SQL Version 10.1.0.4.2 (Production)
    Oracle Procedure Builder V10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle Query Builder 10.1.2.0.2 - Production
    Oracle Virtual Graphics System Version 10.1.2.0.2 (Production)
    Oracle Tools GUI Utilities Version 10.1.2.0.2 (Production)
    Oracle Multimedia Version 10.1.2.0.2 (Production)
    Oracle Tools Integration Version 10.1.2.0.2 (Production)
    Oracle Tools Common Area Version 10.1.2.0.2
    Oracle CORE     10.1.0.4.0     Production
    I have created external directory and am able to load pdf files in oracle database table called test_blob.
    CREATE TABLE test_blob (
    id NUMBER(15)
    , file_name VARCHAR2(1000)
    , image BLOB
    , timestamp DATE
    I have 2 pdf files in the table. I want to view this pdf from forms when the user clicks on the button. On when-button-pressed trigger I want to show pdf on the screen. Any help is appreciated. Not on the designer. I want to run form application.
    SELECT id, file_name,
    DBMS_LOB.GETLENGTH(image) Length,
    timestamp
    FROM test_blob
    ID|FILE_NAME|LENGTH|TIMESTAMP
    1001|2011 HeartlandEmployeeReferralCard.pdf|353718|1/28/2013 11:44:41 AM
    1002|2011 HeartlandEmployeeReferralCard.pdf|353718|1/28/2013 11:51:07 AM
    Edited by: user_anumoses on Jan 28, 2013 11:45 AM

    We were able to do the same thing with Oracle Application Server and Oracle WebLogic Server. I cannot remember how different the processes were, but it seems like they were very similar. I am going to give you the instructions on how we implemented a "Read PDF" procedure on the WebLogic Server. If you are still on the Application Server you may have to do some Google searches, but it all boils down to the mod_plsql DAD Configuration file.
    Our PDF was located in a table with the following structure:
    CASE_DOCUMENTS
       (id_document                    NUMBER NOT NULL,
        doc_blob                       BLOB,
        note                           VARCHAR2(240),
        created_by                     VARCHAR2(20) NOT NULL,
        created_dt                     DATE NOT NULL,
        case_id                        NUMBER NOT NULL,
        filename                       VARCHAR2(100) NOT NULL)Based on that table structure we created a procedure named READ_PDF which you will reference below in the dads.conf file below:
    CREATE or REPLACE procedure read_pdf (p_id_document IN number)
    is
      view_file     blob;
    BEGIN
      select doc_blob
        into view_file
        from case_documents
       where id_document = p_id_document;
      OWA_UTIL.MIME_HEADER ('APPLICATION/PDF', FALSE);
      HTP.P ('CONTENT-LENGTH: ' || DBMS_LOB.GETLENGTH (view_file));
      OWA_UTIL.http_header_close;
      WPG_DOCLOAD.download_file (view_file);
    END;
    GRANT EXECUTE ON read_pdf TO financial_user_role  -- Name of role to execute
    /Basically, you are passing in one parameter and that is the primary key for your table. You are selecting the pdf stored in a BLOB for that primary key. The commands below that allow the pdf to open up so you can view it – we got this off some search we did a few years ago.
    Now, you need to add logic to your Oracle Form that will call the procedure above, but the URL is based on the dads.conf file that we will set up below… Anyway, we created a button on the form module with a label of "View". In the WHEN-BUTTON-PRESSED trigger the logic looks like this:
    -- The View logic uses the DAD (Database Access Descriptors) method to view a .pdf file from the form.
    -- The DAD was created on WebLogic Server  with the name findadgen.  This allows an http request be made
    -- to the database.
    declare
      v_file          varchar2(400);
      v_success       boolean;
      ret_val         number;
      v_http_link     varchar2(400);
    begin
      -- The format of the link is as follows: hostname:port/pls/DAD_name/procedure_name
      v_http_link := 'http://finas03:8888/pls/findadgen/read_pdf?p_id_document=' || :case_documents.id_document;
      web.show_document(v_http_link, '_BLANK');
    end;The name of our WebLogic Server is "finas03" so that is what is listed in the URL. The "findadgen" is the name of the <Location> in the dads.conf file below, the "read_pdf" is the name of the procedure we created above, the "p_id_document=" is the IN parameter listed in the READ_PDF procedure created above, and the ":case_documents.id_document" is the reference to the primary key in our Oracle Form.
    For WebLogic, you can either go through Enterprise Manager (directions below) or update the dads.conf file on the filesystem directly (if you update the dads.conf file directly then skip to step 4 and ignore step 5):
    1.     Enterprise Manager -> Web Tier -> ohs1
    2.     Oracle HTTP Server (pull-down) – Administration – Advance Configuration
    3.     Select File – dads.conf
    4.     Add something similar:
    # ============================================================================ 
    #                     mod_plsql DAD Configuration File                         
    # ============================================================================ 
    # 1. Please refer to dads.README for a description of this file                
    # ============================================================================  
    # Note: This file should typically be included in your plsql.conf file with 
    # the "include" directive. 
    # Hint: You can look at some sample DADs in the dads.README file 
    # ============================================================================
    <Location /pls/findadgen>
        SetHandler pls_handler
        Order allow,deny
        Allow from All
        AllowOverride None
        PlsqlDatabaseUsername financial
        PlsqlDatabasePassword sdo_3#d1
        PlsqlDatabaseConnectString ffindbTNSFormat
        PlsqlNLSLanguage AMERICAN_AMERICA.WE8ISO8859P1
        PlsqlAuthenticationMode Basic
        PlsqlDefaultPage read_pdf
    </Location>You are adding the <Location> section to your dads.conf file. The "finddadgen" is the name that you will reference in a change you fill make to your Oracle Form. The "financial" is the Schema, the "sdo_3#d1" is the password for that Schema, the "ffindb" is the database that the stored procedure is located on, and the "read_pdf" is a stored procedure you will have to create in order to read the pdf.
    5.     Press the "Apply" Button
    6.     Obfuscate the DAD password by running the dadTool.pl script located in $ORACLE_HOME/bin (This was done on Unix on our server with the following commands):
    $> LD_LIBRARY_PATH=$ORACLE_HOME/lib;export LD_LIBRARY_PATH
    $> cd $ORACLE_HOME/bin
    $> perl dadTool.pl -f /u01/app/oracle/middleware/asinst_1/config/OHS/ohs1/mod_plsql/dads.conf
    7.     Restart the Oracle HTTP Server using Fusion Middleware Control:
    Enterprise Manager -> Web Tier -> ohs1
    Oracle HTTP Server – Control – Shutdown
    Oracle HTTP Server – Control – Start Up
    If you followed the instructions above, you should have created a stored procedure, added logic to your Oracle form to reference that stored procedure, and created an entry in the dads.conf file. Once you move the form onto the server and you restart the HTTP Service, you should be able to view a pdf that is stored in a table directly from your Oracle Form.

  • Link multiple  XML files  stored in oracle database

    Link multiple XML files
    Can any one give some code example regarding my issue:
    If I have for example file1.xml stored in one relational table and another file2.xml stored in another table ….etc
    And I want to put link and reference which will make me able to link these files and make query or insert…etc
    May be I need to use Xlink, Xpoiner or Xinclude . But if this is the solution to this problem please can you give a simple example that will help to understand the solution especially that I want to develop my project in oracle and I will register xml schema to insert the xml files in the database
    Thanks lots and I am waiting for your solution

    no answer for my question
    is this thread is a write place or I have to move my query to another part of the forum
    thanks

Maybe you are looking for

  • Is there a way to see and have control over who connects to your time capsule wifi network?

    Ok, have this question. Have a time capsule wifi network. Have the latest mountain lion on my mac pro. I know if you go into airport utility, and you click on the picture of my timecapsule it shows what clients are connected to my time capsule aka us

  • Iphone "find my phone" app not recognizing my phone as a device

    The "find my phone" app will recognize my ipad as a device and locates it properly. However it will not find my phone and is not recognized as a device in the setting section. I've already gone into the settings -> icloud -> find my phone section and

  • What is the best way of exporting artboards from Illustrator for use in InDesign?

    Hi, I have an artboard in Illustrator CS6 which contains some text with a scribble effect applied to it.  I would like to use this text in an InDesign CS6 document.  I am wondering what the best way of exporting/importing this artboard would be so th

  • MSS: Approve working times

    Dear experts, a user runs a MSS transaction "Approve working times" but he receives the message: "No data exists that needs to be approved". The user who runs this transaction is holder of chief position in the organizational plan and one position re

  • Groupy by error

    Hi, I have the following query SELECT tab1.id,tab1.hour,AVG(TO_DATE(TO_CHAR(max(tab1.date), 'mm/dd/yyyy hh24:mi:ss'), 'mm/dd/yyyy hh24:mi:ss') - TO_DATE(TO_CHAR(MIN(tab2.date), 'mm/dd/yyyy hh24:mi:ss'), 'mm/dd/yyyy hh24:mi:ss')) * 24*60*60 avg_second