Home » SQL & PL/SQL » SQL & PL/SQL » Removing specific line from file using UTL_FILE (11g)
Removing specific line from file using UTL_FILE [message #652575] Tue, 14 June 2016 04:16 Go to next message
harshadsp
Messages: 100
Registered: August 2008
Senior Member

Hi,
Could we delete any specific line from a flat file which I am reading using UTL_FILE based on some validation? Line may be first, last or in between any location of file.

Please advise, thanks!
Re: Removing specific line from file using UTL_FILE [message #652576 is a reply to message #652575] Tue, 14 June 2016 04:22 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Yes you can.
Just read the file and wrote it back without the line you don't want.
Is this the best way to do it? inside the database for something that is outside it? Surely not.

[Updated on: Tue, 14 June 2016 05:29]

Report message to a moderator

Re: Removing specific line from file using UTL_FILE [message #652580 is a reply to message #652576] Tue, 14 June 2016 04:58 Go to previous messageGo to next message
harshadsp
Messages: 100
Registered: August 2008
Senior Member

Thanks Michel. You mean to say I need to approach this something with shell or perl? Surely utl_file is not a good option to do this.
Re: Removing specific line from file using UTL_FILE [message #652582 is a reply to message #652580] Tue, 14 June 2016 05:29 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Yes this is what I mean.

Re: Removing specific line from file using UTL_FILE [message #652583 is a reply to message #652582] Tue, 14 June 2016 05:31 Go to previous messageGo to next message
harshadsp
Messages: 100
Registered: August 2008
Senior Member

Thanks Michel, I will try with one of those as well.
Re: Removing specific line from file using UTL_FILE [message #652589 is a reply to message #652583] Tue, 14 June 2016 06:49 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
harshadsp wrote on Tue, 14 June 2016 05:31
Thanks Michel, I will try with one of those as well.


If a shell script is an acceptable solution, then using 'grep' in that script makes the exercise trivial.
Re: Removing specific line from file using UTL_FILE [message #652679 is a reply to message #652589] Thu, 16 June 2016 02:33 Go to previous message
harshadsp
Messages: 100
Registered: August 2008
Senior Member

Thanks @EdStevens. I am trying this with Shell script.
Previous Topic: TO_NUMBER function not working
Next Topic: Calculating values from two different tables by using SQL command.
Goto Forum:
  


Current Time: Fri Apr 26 08:25:11 CDT 2024