How to append a character using UTL_FILE pkg

A table with student_id, student_name and date_of_join.
create table student(std_id varchar2(10),std_name varchar2(20),std_doj date);I am loading the data from the below flat file using UTL_FILE package
101   ron   04081999
101   ron   01081996
102   ram   05082000
102   ram   12101999
103   fin   06082001
104   gin   07082002
105   gem   08082003I am using a procedure to load the data into table using UTL_FILE package
Students with id's 101 & 102 have two joining dates as they have registered for two courses. In flat file there is no change in std_id but I have to append a character "C" to those who have registered for the second course.
I have to append a character to std_id column. for eg: After loading the result what I am expecting is
std_id          std_name          std_doj
101          ron               04081999
101C          ron               01081996
102          ram               05082000
102C          ram               12101999
103            fin                06082001
104             gin               07082002
105             gem               08082003          Can you please give me an idea on how to get the above result using UTL_PACKAGE in the procedure?

It has nothing to do with UTL_FILE. In your load procedure you are looping through the file line by line, right? SO you need to :
DECLARE
    prev_std_id number;
BEGIN
    LOOP
      read a line
      parse it into std_id, std_name and std_doj
      IF std_id = prev_std_id
        THEN
          std_id := std_id  || 'C';
        ELSE
          prev_std_id := std_id;
      END IF;
      insert row
    END LOOP;
END;SY.

Similar Messages

  • How to read HTML files using UTL_FILE

    Hello Friends,
    How to read HTML files using UTL_FILE package ? According
    to Oracle documentation UTL_FILE can read or write OS Text Files.
    Thanx in advance..
    Adi

    HI Hareesh,
    i have gone through that blog.
    i tried it...but i am getting mapping error  no receiver determination fond because there are so  many excel files.
    my data is available on sharedString.xml but also it is in not same order.
    i have no clue how to handle this part form the blog.
    "This way our mapping will receive all data from the sheet in an XML format. The only thing that's left is to create an XSD file from the XML file we received in order to be able to use it in the mapping and as our Service Interface and we can proceed with mapping. As you can see from the sheet.xml files all the data is placed with column name and row number so it's not that difficult to map it to an table type format using the Message Mapping only (no java, abap mapping required)."

  • How to append DB records using OdiSqlUnload tool

    Hi
    Can any one please help me on how to append DB records using OdiSqlUnload tool.
    Work Scenario: I created a loop in a package and want to stored error records into xls file. I tried, but it is storing only recent record got failed
    Any sugession or help on OdiSqlunload tool
    Thanks
    Phani

    Hi Guru,
    I tried It is storing last record but I want to store all failure records (which are in a loop) into excel file
    Please help me
    Thanks
    Phani
    Edited by: Phanikanth on Jul 15, 2010 8:25 PM

  • Concatenating file using utl_file pkg.

    Hi ,
    I have files generated every 10 mins. I have to concatenate all these files for every 5 hours and distribute that file to client locations.
    can u plz. tell me is it possible to concatenate small but huge number of files
    using utl_file package.
    Help needed !!
    Thanks in advance

    Hi Guido
    Thanks for the reply ..
    But can i call this shell script from oracle procedure ...
    As i have this files in DB server and i don't have my java there ...
    I have to invoke this shell script from oracle ...

  • How to Insert Character using Prepared statement

    Hi All,
    Can anyone let me know how can I insert character using prepared statement.
    Thanks
    Sameer

    In the future JDBC related questions should be posted into the JDBC forum.
    Can you please provide some more information about what you are trying to do? It isn't clear to me. Are you trying to update a CHAR field?

  • How to set encoding of the file when using UTL_FILE

    Hi,
    We are using HRMS 11i applications. 11.5.10.2 version. Two languages are installed in our instance. American English and Canadian French.
    We have requirement to send employee details in a text file to third party vendor. We are using UTL_FILE to write details to the text file from PL/SQL procedure.
    The generated output file has encoding as "UTF8". Where as vendor is not able to process this file. They required encoding as "ANSI".
    How can we change the encoding to "ANSI" ?
    Values of character set parametrs are as follows.
    NLS_CHARACTERSET UTF8
    NLS_NCHAR_CHARACTERSET UTF8
    Any inputs are highly appreciated.
    Regards,
    Veerababu.

    You should take a look at the UTL_FILE documentation. As far as I know standard UTL_FILE calls write to the file system in the database character set. There are mirrored calls, but those write to the file system in UTF8.
    You may want to look at the UTL_RAW.CONVERT function. You may be able to use that in conjunction with the UTL_FILE.PUT_RAW API to write out data in the correct character set. To be honest, I've never tried this approach.
    Edited by: Centinul on Sep 21, 2012 8:16 AM

  • How to append paragraph in text file of TextEdit application using applescript

    how to append paragraph in text file of TextEdit application using applescript and how do i save as different location.

    christian erlinger wrote:
    When you want to print out an escape character in java (java is doing the work in client_text_io ), you'd need to escape it.
    client_text_io.put_line(out_file, replace('your_path', '\','\\'));cheersI tried replacing \ with double slash but it just printed double slash in the bat file. again the path was broken into two lines.
    file output
    chdir C:\\DOCUME~1\
    195969\\LOCALS~1\\Temp\
    Edited by: rivas on Mar 21, 2011 6:03 AM

  • How do I use UTL_FILE to insert a large number of fields to a file?

    Hi
    I am trying to use UTL_FILE for the first time in a Stored Procedure. I need to run a complex query to select 50 fields from various tables. I need these to be inserted into one line in the output file for all rows. Is this possible? My procedure so far is like the following
    CREATE OR REPLACE PROCEDURE PROC_TEST IS
    output_file UTL_FILE.FILE_TYPE;
    BEGIN
    FOR query in (SELECT FIELD1, FIELD2, ..........FIELD50)
    FROM TABLE A, TABLE B
    WHERE A.ID = B.ID
    ETC
    LOOP
    UTL_FILE.PUT_LINE(output_file, <put all 50 fields for all records into file> );
    END LOOP;               
    UTL_FILE.FCLOSE (output_file);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
         UTL_FILE.FCLOSE_ALL;
    RAISE;
    END PROC_TEST;
    Do I need to define 'query' (after the FOR) anywhere, also please advise with how I put all of the fields into the file.
    Thanks
    GB

    Thanks Steve,
    I have the UTL_FILE working fine now.
    I have other queries to run and conditions to apply in the same procedure, and I need to schedule via Enterprise Manager, therefore using UTL_FILE in a procedure seemed the best option. I looked up Data-pump but this seems to be an 11g feature, and we are still on 10g therefore I will not be able to use it.
    Thanks for your help.
    GB

  • How to read a tab seperated data from a text file using utl_file

    Hi,
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....
    Thanks in advance...
    Naveen

    Naveen Nishad wrote:
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....If it's a text file then UTL_FILE will only allow you to read it a line at a time. It is then up to you to split that string up (search for split string on this forum for methods) into it's individual components.
    If the text file contains a standard structure on each line, i.e. it is a fixed delimited structure, then you could use external tables to read the data instead.

  • HOW TO READ DATA FROM A FILE AND INSERT INTO A TABLE USING UTL_FILE

    Hi..
    I have a file.I want to read the data from file and load it into a table using utl_file.
    how can I do it?
    Any reply apreciated...

    Hi,
    This is not your requirment but u can try this :
    CREATE OR REPLACE DIRECTORY text_file AS 'D:\TEXT_FILE\';
    GRANT READ ON DIRECTORY text_file TO fah;
    GRANT WRITE ON DIRECTORY text_file TO fah;
    DROP TABLE load_a;
    CREATE TABLE load_a
    (a1 varchar2(20),
    a2 varchar2(200))
    ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
    DEFAULT DIRECTORY text_file
    ACCESS PARAMETERS
    (FIELDS TERMINATED BY ','
    LOCATION ('data.txt')
    select * from load_a;
    CREATE TABLE A AS select * from load_a;
    SELECT * FROM A
    Regards
    Faheem Latif

  • How to use UTL_FILE

    Hi ,
    Would like to know how i can use UTL_FILE :
    This is an sample from the web :
    declare
    f utl_file.file_type;
    s varchar2(200) := 'this is some info';
    begin
    f := utl_file.fopen('SAMPLEDATA','sample2.txt','W');
    utl_file.put_line(f,s);
    utl_file.fclose(f);
    end;
    where does SAMPLEDATA i.e the location points to ? if i have a pl/sql program running on my PC is it refering to the path in my PC on in the database's SERVER ?
    pls advise
    tks & rgds

    Hi!
    Pls go through the following document.
    http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/x/Utl_File/start.htm .
    Regards.
    Satyaki De.

  • How to read a .CSV file using UTL_FILE

    HI,
    How do i read a .csv file line by line using UTL_FILE?
    Thanks in advance
    Regards,
    Gayatri

    ----do open the file logic
    begin
    ----Let's say this file is delimited by ','
    ---declare variables
    v_startPos number; -- starting position of field
    v_Pos number; -- position of string
    v_lenString number; -- length
    v_first_field varchar2(30);
    v_second_field varchar2(30);
    v_third_field varchar2(30);
    v_fourth_field varchar2(30);
    input_String varchar2(1000); -- buffer for each line of file
    ----Say you have a 4 column file delimited by ','
    delimitChar varchar2(1) := ','
    Joe;Joan;People;Animal
    Teddy;Bear;Beans;Toys
    begin
    loop
    utl_file.get_line(input_file, input_String); -- get each line
    ---- this will get the first field as specified by the last number
    v_Pos := instr(input_String,delChar,1,1);
    v_lenString := v_Pos - 1;
    v_first_field := substr(input_String,1,v_lenString);
    v_startPos := v_Pos + 1;
    -- this will get the second field
    v_Pos := instr(inString,delChar,1,2);
    v_lenString := v_Pos - v_startPos;
    v_second_field := substr(input_String,v_startPos,v_lenString);
    v_startPos := v_Pos + 1;
    -- 3rd field
    v_Pos := instr(inString,delChar,1,3);
    v_lenString := v_Pos - v_startPos;
    v_third_field := substr(input_String,v_startPos,v_lenString);
    v_startPos := v_Pos + 1;
    -- last field -- there is no delimiter for last field
    v_Pos := length(input_String) + 1;
    v_lenString := v_Pos - v_startPos;
    v_fourth_field := substr(input_String,v_StartPos,v_lenString);
    end;
    EXCEPTION
    WHEN no_data_found then
              fnd_file.put_line(FND_FILE.LOG, 'Last line so exit');
              exit;
    end loop;

  • How to download the chinese character using GUI_DOWNLOAD

    How to download the chinese character using GUI_DOWNLOAD from SAP 4.6c

    Hi,
       Make sure that the chinese font is installed in your system, because when you download in excel, the character formats are taken from the Frontend.  For detail see the below thread.
    [link1|Re: Download Chinese character]
    Thanks,
    Asit Purbey.

  • How to Append two  word documents into single  using   java

    How to Append two word documents into single using java
    we tried this but it's not append the one word document to other
    source code:public class AppendTwoWordFiles {
         public static void main(String []arg)throws IOException
              FileInputStream fi=null;
              FileOutputStream fo=null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                   File f1=new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2=new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2,true);
                   byte b[]=new byte[2];
                   while((fi.read(b))!=-1);
              fo.write(b);
    System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              finally{
              fi.close();
              fo.close();
    plz reply me quickly ,,,what can i follow

    Use this code ..
    and give the path of the both file like this.....
    source file ---- C:/workspace/Practice/src/com/moksha/ws/test/practice.text
    destination file ---- C:/workspace/City/src/com/moksha/ws/test/practice1.text
    import java.io.*;
    public class AppendTwoWordFiles {
         public static void main(String[] arg) throws IOException {
              FileInputStream fi = null;
              FileOutputStream fo = null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br = new BufferedReader(new InputStreamReader(
                             System.in));
                   File f1 = new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2 = new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2, true);
                   byte b[] = new byte[2];
                   int len = 0;
                   while ((len = fi.read(b)) > 0) {
                        fo.write(b, 0, len);
                   System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              } finally {
                   fi.close();
                   fo.close();
    }

  • How to do an inbound and outbound interfacing using UTL_FILE ?

    dear members,
    How can we do interfacing from a legacy system to oracle and vice versa using the UTL_FILE package. I mean how to do an INBOUND and OUTBOUND interfacing using utl_file.
    regards
    sandeep

    in/
    file/
    bad/
    done/
    out/
    file/
    bad/
    done/
    I would start by ftping / putting the file in in/file/ folder, once ftp has completed move it to complete/ folder and process the file. If errorrs are generated move the file over to bad folder. If completed successfully move over to done folder.
    Having said that you would use UTL_FILE_DIR init parameter to set your directory.
    ALTER SYSTEM SET UTL_FILE_DIR='directory1','directory2' scope=spfile;
    Then you would use the regular utl_file packages to read / write to the files.
    UTL_FILE.FOPEN and so on.

Maybe you are looking for

  • Add Button Column in IR

    Hi, I have created an Interactive report on a table. I want to add two buttons in each row: Accept and Reject, so that i can change the status(db column) of the corresponding record on button action. How can I do so?

  • Mapping of logical resource-name to absolute jndi-name for data source

    Hi, I am using SJS AS 8.1. I do a lookup for datasource using logical name specified in ejb-jar.xml using resource-ref element as below : <resource-ref>         <res-ref-name>jdbc/db-resource</res-ref-name>         <res-type>javax.sql.DataSource</res

  • Sales order profit booking in another country

    Hi All I have a requirement for which, even after informing the customer that it is not possible to address in SAP, the customer wants us to give them solution. In spite of we giving them several suggestions to re-engineer the process, they want it t

  • Site update strategies query.

    I've got my iWeb site up and running now, and I'm very happy with it. I've incorporated Haloscan comments via iComment as well as StatCounter. The problem is that the "post-processing" that I do is lost each time I decide to add a blog entry or other

  • Object Project Definition could not be created

    Hi Experts, I am facing some trouble with multilevel controlling integration. Whenever I transfer a project I am getting the following error in cProjects: Costing data may not be up-to-date  Display Help Error occurred in accounting - see controlling