Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: writing something in a text file in specific location using utl_file ???
On Feb 22, 11:37 pm, "Valentin Minzatu" <valentinminz..._at_yahoo.com>
wrote:
> On Feb 22, 9:14 am, "hpuxrac" <johnbhur..._at_sbcglobal.net> wrote:
>
>
>
>
>
> > On Feb 22, 8:30 am, "ganesh bora" <lalitmohanpa..._at_gmail.com> wrote:
>
> > > On Feb 22, 4:44 pm, "hpuxrac" <johnbhur..._at_sbcglobal.net> wrote:
>
> > > > On Feb 22, 4:48 am, "ganesh bora" <lalitmohanpa..._at_gmail.com> wrote:
>
> > > > > Hi all,
> > > > > Actuly I m trying to write someting in a text file in the specified
> > > > > location, which function have to use from utl_file package in order
> > > > > to do this ....???
> > > > > let me clear this actuly what i m trying to do is ..
>
> > > > > like i have one text file and it contains the text like ----
> > > > > hi how r u
>
> > > > > and i want to replace r with are in the same file using the
> > > > > plsql procedure ...
> > > > > to do this which function i have to use ....
>
> > > > > there is one fseek function which i know to change the cursor
> > > > > location ...
>
> > > > > and one more thing can we not open an text file in read&write
> > > > > both modes like in c language in plsql ....
>
> > > > > plz give me some ideas or example
>
> > > > > Thanks to all
>
> > > > What specific problems are you having?
>
> > > > What does your current code look like?
>
> > > > You will probably get more help if you supply something that shows you
> > > > at least did a little work on it before submitting it to cdos.- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > Actuly i m trying to write a procedure in plsql through which I can
> > > replace any string in the text file ....
> > > for example ....
> > > I have a text file named test.txt which contains data like
>
> > > hi its just a test.
>
> > > now i want to replace its with it is after which the file
> > > contains something like
> > > hi it is just a test.
>
> > > I was able to append the data on the text file , or i can over write
> > > it .... but ... if there is any function through which i can write any
> > > data to a text file in any position that is specified by me.
>
> > > to write the data i m using this ...
>
> > > --code to write data to text file
> > > declare
> > > f utl_file.file_type;
> > > s varchar2(200) := 'hi its just a test;
> > > begin
> > > f := utl_file.fopen('READ_LOB_DIR','test.txt','W');
> > > utl_file.put_line(f,s);
> > > utl_file.fclose(f);
> > > end;
>
> > > Thanks waiting 4 ur response
>
> > Java is probably much better than plsql utl_file if you want to be
> > able to read or write "any record" randomly.- Hide quoted text -
>
> > - Show quoted text -
>
> Could notepad, wordpad or vi do the job for you?- Hide quoted text -
>
> - Show quoted text -
some times ideas doesn't click ... thanx anyways for all of u ...
create or replace procedure
write_replace (v_input varchar2,v_replace varchar2)
is
file utl_file.file_type; str varchar2(2000); pos number; len number; pos_start number :=1; pos_end number; diff number; output varchar2(2000); begin --open the file in read mode file := utl_file.fopen('READ_LOB_DIR','test.txt','r') ; --read the file and strore the contents of file in str variable utl_file.get_line(file,str); --close the file utl_file.fclose(file); str := replace(str,trim(v_input),trim(v_replace));--open the file in write mode
![]() |
![]() |