2 Replies Latest reply: Feb 23, 2010 3:24 AM by Zeeshan BaiG RSS

    using text_io package

    755629
      can anyone paste the code here to read a text file and modify the data using substring command and put the same line by line into another text file.
        • 1. Re: using text_io package
          Sarah
          hi

          try this.

          PROCEDURE  ConvertToTextFile  is
          cursor c1 is select distinct empno , ename , dept.deptno , dname ,loc from dept,emp;
               out_file  TEXT_IO.FILE_TYPE;
               emp_no VARCHAR2(10);
               bank_no VARCHAR2(20);
               emp_name VARCHAR2(45);
               salary VARCHAR2(11);
               v_a   VARCHAR2(51);
               d_name        VARCHAR2(51); 
               loc           varchar2(50);
               empno varchar2(20);
               ename varchar2(20);
          begin
            out_file := TEXT_IO.FOPEN('c:\SAL.txt', 'a');
             TEXT_IO.PUTF(out_file,'DeptN        DName              loc     empno     ename   ' ||CHR(10)); 
             TEXT_IO.PUTF(OUT_FILE,'======       =====              ======   =====     ======  ' ||CHR(10)); 
                for i in (select distinct empno,ename,dept.deptno , dname ,loc   from dept,emp  ) loop 
                emp_no  := rpad(to_char(i.deptno),10,' ');
                 d_name := rpad(i.dname,20,' ');
                loc := rpad(i.loc,10,' ');
                empno := rpad(i.empno,10, ' ');
                ename := rpad(i.ename,20, ' ');
          
                 --TEXT_IO.PUT(out_file, emp_no||' '||d_name|| ' ' || loc || '');
                --TEXT_IO.PUT(out_file, emp_no||' '||d_name||chr(10) || loc);
                TEXT_IO.PUT_LINE(out_file, emp_no||' '||d_name|| ' ' || loc ||empno || ename ||' ');
                End loop;
               TEXT_IO.NEW_LINE(out_file, 2);
          TEXT_IO.FCLOSE(out_file);
          --host('C:\WINDOWS\notepad.exe','c:\sal.text');
          host ( 'cmd /C start "" "' || 'c:\sal.txt' );
          
          
          
          end;
          
          
          {code}
          
          
          sarah                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
          • 2. Re: using text_io package
            Zeeshan BaiG
            download the example from here

            http://baigsorcl.blogspot.com/2010/01/open-file-dailog-box-example-using.html