Help needed in reading text file to database table

Hello experts,
i have to insert the values from the column of this text file and insert them in my database table.
I have done a few file to table insertions but i'm having some trouble with this one.
Any suggestions plz
thanks
liab_report      1.00                                                                                                                              Page: 1
CDC:00537 / Mon Jun-21-2010                           LIABILITY REPORT                               Mon Jun-21-2010 22:06:26
DRAW    1; SET    1;  November 7, 2009
                     TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                   WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
  DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
    Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
    Div2         701040.00          0.00     660146.00          0.00      40894.00    0.00          0.00
    Div3        1444128.00          0.00    1330056.00          0.00     114072.00    0.00          0.00
    Div4        4711900.00          0.00    3889700.00          0.00     822200.00    0.00          0.00
                6857068.00          0.00    5879902.00          0.00     977166.00    0.00          0.00
DRAW    2; SET    1;  November 14, 2009
                     TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                   WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
  DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
    Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
    Div2         817817.00          0.00     817817.00          0.00          0.00    0.00          0.00
    Div3        1687405.00          0.00    1611742.00          0.00      75663.00    0.00          0.00
    Div4        3402100.00          0.00    3034200.00          0.00     367900.00    0.00          0.00
                5907322.00          0.00    5463759.00          0.00     443563.00    0.00          0.00
DRAW    3; SET    1;  November 21, 2009
                     TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                   WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
  DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
    Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
    Div2         779933.00          0.00     769804.00          0.00      10129.00    0.00          0.00
    Div3        1605548.00          0.00    1525104.00          0.00      80444.00    0.00          0.00
    Div4        4891700.00          0.00    4256800.00          0.00     634000.00    0.00        900.00
                7277181.00          0.00    6551708.00          0.00     724573.00    0.00        900.00

Plz clarify whether u want to load text file as a file into database or value of this text file into database. If values are to be loaded from this text file, U can better format the text file and use SQL loader to load the file into database. By formatting the database, i mean remove the unnecessary headings and characters, kee only the values to be loaded idelimited by ' '(space) or ','(comma). Create a control file and load it into the target table.

Similar Messages

  • Need to read text file content and have to display it in multiline text box

    dear all,
    Need to read text file content and have to display it in multiline text box.
    actually im new to file handling. i have tried up to get_line and put_line.
    in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
    TEXT_IO.GET_LINE (in_file,linebuf);
    i dont know how to assign this get_line function to text item
    pls help me in this regards,

    Simply write:
    in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
    TEXT_IO.GET_LINE (in_file,linebuf);
    :block2.t1 := chr(10)||:block2.t1||chr(10)||linebuf;
    chr(10) --> is for new line character

  • Read text file insert into table using utl_file

    Hi
    i have script for read and insert into table but i want error records load into error table so i sent you my script and please fix the error log table
    script
    DECLARE
    v_line VARCHAR2(2000);
    v_file utl_file.file_type;
    v_dir VARCHAR2(250);
    v_filename VARCHAR2(50);
    BEGIN
    v_dir :='MID5010_DOC1TP';
    v_filename := 'OPT_CM_BASE.txt';
    v_file := utl_file.fopen(v_dir, v_filename, 'r');
    LOOP
    BEGIN
    utl_file.get_line(v_file, v_line);
    EXCEPTION
    WHEN no_data_found THEN
    EXIT;
    END ;
    v_line := REPLACE(v_line,'|','|~');
    INSERT
    INTO optum_icd10cm_base VALUES
    ( REPLACE(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,1),'a~','a'),'.'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,2),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,3),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,4),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,5),'a~','a'),
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,6)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,6),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,6),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,7)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,7),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,7),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,8)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,8),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,8),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,9)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,9),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,9),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,10)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,10),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,10),'a~','a'),'mm-dd-yyyy')
    END,
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,11),'a~','a')
    -----commit;
    END LOOP;
    utl_file.fclose(v_file);
    END;
    text file
    A50.0||Short|Long|Full|01-01-2009|01-2009||01-01-2013|09-18-2012|C|
    A50.1||Short|Long|Full|01-01-2009|01-01-2009||001-2013|09-18-2012|C|
    A50.2||Short|Long|Full|01-01-2009|01-01-2009|67|01-01-2013|09-18-2012|C|
    A50.3||Short|Long|Full|011-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.4||Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|5|
    A50.5|R|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.6||Short|Long||01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.7||Short||Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    2345||Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.8|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.9|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    B222|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.8|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.9|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.2|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.3|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    D642|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.5|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.6|D|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.7|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A001|C|Short Updated|Long Updated|Full Updated|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A009|C|Short Updated|Long Updated|Full Updated|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.10|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A0109|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A30|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A316|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A317|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    ----clearly read text file insert into table and error records load into error table
    please help me

    hI
    i am using utl_file prepared script but i got error like 01861. 00000 - "literal does not match format string"
    script:
    DECLARE
    f utl_file.file_type;
    s VARCHAR2(32000);
    f1 VARCHAR2(100);
    f2 varchar2(100);
    F3 VARCHAR2(100);
    F4 VARCHAR2(100);
    F5 VARCHAR2(100);
    F6 DATE;
    F7 DATE;
    F8 DATE;
    F9 DATE;
    F10 DATE;
    f11 CHAR(1);
    BEGIN
    --DBMS_OUTPUT.ENABLE(100000);
    f := utl_file.fopen('MID5010_DOC1TP', 'OPT_CM_BASE.txt', 'R');
    LOOP
    BEGIN
    UTL_FILE.GET_LINE(f, s);
    f1 := REGEXP_SUBSTR (s,'[^|]+',1,1);
    f2 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,2);
    F3 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,3);
    F4 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,4);
    F5 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,5);
    F6 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,6),'mm-dd-yyyy');
    F8 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,8),'mm-dd-yyyy');
    F7 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,7),'mm-dd-yyyy');
    F9 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,9),'mm-dd-yyyy');
    F10 :=to_date(REGEXP_SUBSTR (REPLACE(s,'||','||') ,'[^|]+',1,10),'mm-dd-yyyy');
    f11 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,11);
    INSERT
    INTO OPTUM_ICD10CM_BASE
    ( CODE,
    STATUS,
    SHORT_DESCRIPTION,
    LONG_DESCRIPTION,
    FULL_DESCRIPTION,
    CODE_EFFECTIVE_DATE,
    CHANGE_EFFECTIVE_DATE,
    TERMINATION_DATE,
    RELEASE_DATE,
    CREATION_DATE,
    VALIDITY
    VALUES
    F1,
    F2,
    F3,
    F4,
    F5,
    F6,
    F7,
    F8,
    F9,
    F10,
    f11
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    UTL_FILE.FCLOSE(F);
    END;
    please help me(in my org looks utl_file standards only)

  • How to extract data from  text file to database table

    Hi ,
    I am trying to upload  data in text file to database table  using GUI_UPLOAD function .what would be the program for that.
    thanks in advance.

    Hi,
    I don't think you have a standard sap program to upload data from file to database table...
    Instead you can create a custom program like this..
    DATA: T_FILEDATA(1000) OCCURS 0 WITH HEADER LINE.
    DATA: T_ZTABLE LIKE ZTABLE OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = 'C:\TEST.TXT'
      tables
        data_tab                      = T_FILEDATA
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_READ_ERROR               = 2
       NO_BATCH                      = 3
       GUI_REFUSE_FILETRANSFER       = 4
       INVALID_TYPE                  = 5
       NO_AUTHORITY                  = 6
       UNKNOWN_ERROR                 = 7
       BAD_DATA_FORMAT               = 8
       HEADER_NOT_ALLOWED            = 9
       SEPARATOR_NOT_ALLOWED         = 10
       HEADER_TOO_LONG               = 11
       UNKNOWN_DP_ERROR              = 12
       ACCESS_DENIED                 = 13
       DP_OUT_OF_MEMORY              = 14
       DISK_FULL                     = 15
       DP_TIMEOUT                    = 16
       OTHERS                        = 17
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT T_FILEDATA.
      T_ZTABLE = T_FILEDATA.
      APPEND T_ZTABLE.
    ENDLOOP.
    MODIFY ZTABLE FROM TABLE T_ZTABLE.
    COMMIT WORK..
    Thanks,
    Naren

  • Reading Text file or Database efficiently

    Hi.
    I have an option to read EMP names randomly from either text file or database . Can anyone tell me which one will be fast. I have to read more than 5000 names dynamically for my application and pick one name randomly.
    Many thanks, Ravi

    Hi quitte ,
    Thanks for replying. I just want to pick names randomly from file or database to name each and every customer in my application dynamically.
    For this, I created one table with Unique names and would like to design a code such that each customers will be named dynamically.
    Any Suggestions or Advise?
    Ravi

  • Help needed sorting a text file.

    I'm trying to simply open a file, which is a text file of a list of names, then sort that file, the print the sorted file. The problem is that I keep getting this error
    Exception in thread "main" java.util.NoSuchElementException: No line found
         at java.util.Scanner.nextLine(Unknown Source)
         at pro.NamesFile.main(NamesFile.java:36)
    Which is at this line[b] words= new String(inputFile.nextLine());
    It's not reading any lines from the file and I can't figure out why.
    Here's the rest of my code:
    public class NamesFile {
         public static void main(String[] args) throws FileNotFoundException {
              Scanner inputFile;
            inputFile = new Scanner(new File("C:/Documents and Settings/Cougar/Desktop/New Folder (2)/names.txt"));
            String name;
            inputFile.next();
            String[] words = new String[100];
            while (inputFile.hasNext()) {
                 name = inputFile.nextLine();     
                 for (int i = 0; i < words.length; i++) {
                      words[i] = new String(inputFile.nextLine());
            Sort2.insertionSort(words);
                 for (int index=0; index < words.length; index++)
                    System.out.print(words[index].toString()+"\t");
    }Here the sort algoritm I'm using, it the insertion sort one.
    public static void selectionSort (String[] list)
               int min;
               String temp;
               for (int index = 0; index < list.length-1; index++)
                  min = index;
                  for (int scan = index+1; scan < list.length; scan++)
                     if (list[scan].compareTo(list[min]) < 0)
                        min = scan;
                  // Swap the values
                  temp = list[min];
                  list[min] = list[index];
                  list[index] = temp;
            public static void insertionSort (String[] list)
               for (int index = 1; index < list.length; index++)
                    String key = list[index];
                  int position = index;
                  //  Shift larger values to the right
                  while (position > 0 && key.compareTo(list[position-1]) < 0)
                     list[position] = list[position-1];
                     position--;
                  list[position] = key;
            }I'm still relativly new at this, so forgive me if there's something obvious that I'm missing.And thanks for any help anybody can give me.

    You haven't gotten to running the sort yet, so I didn't even check that the sort routine is correct.
    Your problem is:
    You say inputFile.hasNext() once, and then you read 1 line from it. Then, in your 'for' loop, you read 100 lines from it. So, you always attempt to read 101 lines, even if the file is shorter than that.
    You should call "hasNext" before each call to "readLine". Also, you probably want a "while" loop, instead of a "for" loop, since you don't know how many words you will have. I assume you are expecting 100 or less (based on your array size).
    Two more notes:
    1. Don't do "new String(inputFile.readLine())". All you need is:
    words= inputFile.nextLine();
    2. You don't need toString here:
    System.out.print(words[index].toString()+"\t");words[index] is already a String, and concatenating the "\t" to words[index] would create a String, anyway, no matter what type words[index] was. And, calling:
    System.out.print(words[index]);would also automatically call "toString", even if words[index] were not a String.
    You could avoid creation of new Strings by:
    System.out.print(words[index]);
    System.out.print("\t");Just make sure you add braces around them, if both lines are the body of a 'for' loop. You should also make the second 'for' loop into a 'while' loop, using a counter that you update as you read the lines--so that you don't process the "null" elements of the array. You also need to account for null elements in your sort method.

  • Reading text file from database server in OA Page

    Hi Guys,
    I am trying to embed an applet with in an OA Page. The applet is used to mainly for showing Gantt chart. I have to pass my connection details from OA Page to applet, I dont pass directly the connection details to the applet so i am placing all the server details, user name and password in a text file on the database server.
    So from the OA Page i have to read the contents of the file on the database server and pass them to the applet using the <PARAM> tag. My question is how to read the text file from the database server.Any Inputs?
    Thanks in advance for your help.
    Regards,
    Nagesh Manda.

    If the file to be read is on the database, then it makes sense to use the pl/sql code to read the file. Make a call to this pl/sql code from page controller to get back the values.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                           

  • Urgent Help Needed regd reading a file in apex

    Hi all,
    I need to know how can we store content of a file in a variable or any item(like text box).
    i have a os user name in the file.
    when i use apex_util.get_file it is opening in new page.
    instead i want it to stored in a text box or any variable.
    cany any one help me on this.
    Thanks in advance,
    Srini
    Message was edited by:
    user650963

    Hi Srini,
    You can use the normal file upload functionality to do this.
    1 - Create a page region and add in a File Browse item - I'll call it P1_FILE_NAME
    2 - Create a button in that region, I'll call it P1_UPLOAD_BUTTON, and set it to branch back to the same page
    3 - Create a TextArea item - I'll call it P1_FILE_CONTENTS
    4 - Create a page process, called P1_UPLOAD_FILE, and triggered by the P1_UPLOAD_BUTTON
    5 - Use the follownig code for the process:
    declare
    v_clob clob;
    v_blob blob;
    v_varchar2 varchar2(30000);
    BEGIN
    SELECT blob_content into v_blob FROM APEX_APPLICATION_FILES where name = :P1_FILE_NAME;
    v_clob := wwv_flow_utilities.blob_to_clob(v_blob,'utf-8');
    :P1_FILE_CONTENTS := wwv_flow_utilities.clob_to_varchar2(v_clob);
    :P1_FILE_NAME := '';
    delete from APEX_APPLICATION_FILES WHERE NAME = :P1_FILE_NAME;
    END;When you select the file and click the Upload button, the file is uploaded into the APEX_APPLICATION_FILES table. The contents of the file is put into a BLOB field. The above code, converts that BLOB into a CLOB and then into a VARCHAR2 value - you can then change P1_FILE_CONTENTS to that value. Finally, the code removes the file from the table and resets the File Browse field.
    Note that this assumes that the file contains nothing but text and is no more than 30,000 characters in length.
    Andy

  • Reading text file to populate table

    I am getting following error
    5/10/01 1:08 PM Execution failed: ORA-20053: Read Error
    5/10/01 1:08 PM ORA-06512: at line 8
    5/10/01 1:08 PM End Executing PL/SQL block
    When I run the same program in for loop for 100 times it runs fine. But does not work if I run the loop till end of file.
    PROCEDURE READTEXT ( p_FileDir IN varchar2,
    p_FileName IN varchar2,
    p_OpenMode IN varchar2)
    AS
    v_file utl_file.file_type;
    v_line varchar2(2700);
    v_rec_id bu340.rec_id%type;
    v_num_lines bu340.num_lines%type;
    v_typist_orig bu340.typist_orig%type;
    BEGIN
    v_file := utl_file.fopen(p_FileDir,p_FileName,p_OpenMode);
    LOOP
    BEGIN
    utl_file.get_line(v_file,v_LINE);
    EXCEPTION
    when NO_DATA_FOUND then
    EXIT;
    END;
    v_rec_id := substr(v_line,1,4);
    v_typist_orig := substr(v_line,7,2);
    INSERT INTO BU340 (rec_id,typist_orig)
    VALUES (v_rec_id,v_typist_orig);
    END LOOP;
    utl_file.fclose(v_file);
    commit;
    EXCEPTION
    when utl_file.invalid_operation then
    utl_file.fclose(v_file);
    raise_application_error(-20051,'Invalid Operation');
    when utl_file.invalid_FileHandle then
    utl_file.fclose(v_file);
    raise_application_error(-20052,'Invalid FileHandle');
    when utl_file.read_error then
    utl_file.fclose(v_file);
    raise_application_error(-20053,'Read Error');
    when others then
    utl_file.fclose(v_file);
    raise;
    END;
    null

    I guess what is happening is since you have more than 100 records it runs fine if you try 1 .. 100 but if you try end of file it enters the code for exception. The Exit is not working the way you want it to work so it falls through due to which you are getting a read error since there is no data.
    Your Code sample :
    LOOP
    BEGIN
    utl_file.get_line(v_file,v_LINE);
    EXCEPTION
    when NO_DATA_FOUND then
    EXIT;
    END;
    v_rec_id := substr(v_line,1,4);
    You can try either of this
    1. Remove Begin and End statement.
    2. EXCEPTION
    EXIT when NO_DATA_FOUND;
    I guess it is of some help.
    null

  • Read text file and insert into MySQL

    Dears,
    I need to read text file and then insert the data in the correct column in the MySQL database
    example
    I have the following text file:
    field1=1234 field2=56789 field3=444555
    field1=1333 field2=2222 field3=333555
    and so on and so forth ,,note that all rows are identical and just the filed value is changed(there is a dilemeter between fields)
    how can I read field1,field2 and field3 from text file and insert them in the correct table and column in the database.....
    any help?????
    thanks for your cooperation
    Best Regars

    Sure.
    Which part don't you understand?
    1. Reading a text file
    2. Parsing the text file contents.
    3. Relational databases and SQL.
    4. How to create a database.
    5. How to connect to a database in Java.
    6. How to insert records into the database in Java.
    7. How to map Java objects to records in a database.
    This is a pretty nice list. Solve complex problems by breaking them into smaller ones.
    %

  • HOW TO IMPORT HUNDREDS OF TEXT FILE TO DATABASE AS TABLE

    Hi,
    I have hundreds of text files in my computer. Every text file includes records. I want to see these records in one table at the database. How can I do that?
    thank you very much for help
    ömer faruk akyüzlü
    in Turkey

    I have a standard template that my developers use for reading text files using External Tables . Each developer gets an external table to read in test data. The format the data in CSV format, but you could use others. The External Table points to a generic file name, such as "csv_data". They then just rename the file or create a link to it, depending on the OS.
    My solution uses the Directory objects. The following can be put in a script and run passing the first argument as the developers name. It supports a csv file upto 15 columns, but you can expand it.
    -- begin script
    CREATE OR REPLACE DIRECTORY &1 as '/home/&1';
    grant read on directory &1 to public;
    alter session set current_schema=&1;
    --drop table csv_data;
    CREATE TABLE csv_data
    col1 VARCHAR2(250),
    col2 VARCHAR2(250),
    col3 VARCHAR2(250),
    col4 VARCHAR2(250),
    col5 VARCHAR2(250),
    col6 VARCHAR2(250),
    col7 VARCHAR2(250),
    col8 VARCHAR2(250),
    col9 VARCHAR2(250),
    col10 VARCHAR2(250),
    col11 VARCHAR2(250),
    col12 VARCHAR2(250),
    col13 VARCHAR2(250),
    col14 VARCHAR2(250),
    col15 VARCHAR2(250)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY &1
    ACCESS PARAMETERS
    (RECORDS DELIMITED BY newline
    NOBADFILE
    NODISCARDFILE
    NOLOGFILE
    SKIP 0
    FIELDS TERMINATED BY ","
    OPTIONALLY ENCLOSED BY '"'
    RTRIM
    MISSING FIELD VALUES ARE NULL
    REJECT ROWS WITH ALL NULL FIELDS
    col1 CHAR, col2 char,col3 char,col4 char,col5 char,col6 char,col7 char,col8 char,col9 char,
    col10 char,col11 char,col12 char,col13 char,col14 char,col15 char
    LOCATION (&1:'csv_data')
    REJECT LIMIT Unlimited
    NOPARALLEL
    NOMONITORING
    --end script

  • USING WEBUTIL TO READ TEXT FILE INTO TABLE HANGS AFTER CERTAIN NUMBER OF RE

    Dear
    when we use webutil to retrieve data from text file into database table
    (using text_io) it hangs after certain number of records ( approx. 1300
    records) while the total number of records to be inserted in the table exceeds
    12000 records while it works properly on forms6i with the normal text_io any
    help please...?
    thanks and regards

    WebUtil uploads the files as Binary - so yes you could have some issues if you have a Unix host - however, that would only mean that there is an extra character to trim off of the end of the line read by Text_io.

  • ... reading text file to load data

    Hi all.
    we have a requirement, acc to which we need to read a few tab delimited text file into oracle tables on daily bases.
    i was trying to read it through the utl_file procedure, but while working i found out that there is a limitation in utl_file ... you can only read a complete line, and i had no clue how to use the delimiter to read each column and insert into database.
    Another option i have is to use External table, use these text file as external table and insert data into oracle tables.
    There is one problem where i got stuck, probably due to inexperience.
    One of the files we recieve is like .
    SID, teacher1_Name, teacher1_age, teacher1_sex,teacher2_name,teacher2_age, teacher2_sex......
    while the table structure is like
    SID Teacher_name, age sex .... ............
    Now how can i insert the values for teacher1_age into age column...
    so that my db table will be filled like
    S1 teacher1_name teacher1_age teacher1_sex
    S1 teacher2_name teacher2_age teacher2_sex
    Please also suggest that is my method correct for reading these file by making them external tables and then inserting into our db tables.
    The reason i cant keep the files is that the data comes daily with changed values, so we need to read them daily and then delete or replace with the new one coming with same name and struture the next day..
    Regards

    Look at SQL*Loader
    See also an External Table Example

  • How can I read text files from LAN if I only know the hostname?

    I'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
    <p>1. How can I read text files from LAN if I only know the hostname, or IP address?
    <p>2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.
    (ex. how can I read the 120th line?)
    <p>Please help!
    <p>sorry for the bad english

    I'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
    1. How can I read text files from LAN if I only know the hostname, or IP address?You need to know the URL of the file. You need to know the hostname, port, protocl and relative path.
    The hostname is server, not file.
    2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.Use the seek() to get to a random byte.
    (ex. how can I read the 120th line?)The only way to find the 120th line is to read the first 120 lines. You can use other file formats to find the 120th line without reading the whole file but to need to be able to detremine where the 120th line is

  • Reading text file from stored procedure

    Hi
    I have a text file coming daily. I need to read the file.
    1st line contain the file source
    Last line contain the no of records in the file.
    I need to count all the lines in text file compare with the number of lines mentioned in the last line of the file.
    Can any one help me in achieving the above task.
    Thanks a lot in advance.
    KLSRAO

    Re: UTL_FILE Examples

Maybe you are looking for

  • How do I transfer my iTune to another computer?

    Usually for Apple products, it can only sync to one library at a time. If you tried to sync it to another library, it would only allow you if you erase all the contents on your item (iPhone in my case) to replace it with the contents on the other iTu

  • My computer crashes when I try to download ITunes 11.11.1?

    I tried to download ITunes 11.11.1 on both my home computer that has Windows 7 and my mother's laptop which runs on Vista.  Both times, the computers froze and had to go through a Windows repair.  What am I doing wrong?

  • Manual Bank Reconciliation

    Dear All, I have configured all the necessary steps of manual bank reconciliation but the batch input session is not generated. Further m preparing the statement for first time so i have entered the opening balance in the Main Bank G/l. I have entere

  • Procurement for Cost Center

    Hi Guys, Is it Necessary to maintain the G/L A/c while procuring for Cost center?? Or Cost Center is Sufficient ?? Please guide me??

  • User Exit issue after upgrade from 4.6c to ECC 6.0

    Hi Experts, After upgrade we are facing some issues regarding user exit. In 4.6c we have implemented several user exit to do customization in several module like SD,FI and HR. But after upgrade it has been identified that SAP has already provided thi