Home » SQL & PL/SQL » SQL & PL/SQL » Copy database value in text file
Copy database value in text file [message #214823] Thu, 18 January 2007 04:07 Go to next message
romi
Messages: 67
Registered: October 2006
Member

hello all,

I have a database.I want that,after insertion in databse, i can copy that value which has been insert in a text file.Is it possible through trigger? if yes, then how? Or is there any another way to achieve it?
Re: Copy database value in text file [message #214829 is a reply to message #214823] Thu, 18 January 2007 04:17 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
use trigger along with UTL_FILE builting package.
Search board for examples on UTL_FILE.
But why?
Re: Copy database value in text file [message #214832 is a reply to message #214823] Thu, 18 January 2007 04:20 Go to previous messageGo to next message
romi
Messages: 67
Registered: October 2006
Member


Thank u rajendran, Can u give me 1 example that i can understand it easily.
Re: Copy database value in text file [message #214833 is a reply to message #214823] Thu, 18 January 2007 04:21 Go to previous messageGo to next message
Cthulhu
Messages: 381
Registered: September 2006
Location: UK
Senior Member
I've never tried it, but you may be able to write it to an external table using the trigger. Alternatively, you could just write a select statement and spool it to a file using SQL*Plus.
Re: Copy database value in text file [message #214838 is a reply to message #214832] Thu, 18 January 2007 04:31 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Many many examples in this forum. Please search. One such is
http://www.orafaq.com/forum/m/73347/42800/?srch=write_log#msg_73347
If you are using 9i and above, use create directory.
If you want to append into the same file, UTL_FILE is easy.
If you wnat to write to seperate files everytime, SPOOL is much easier ( as CTulhu has kindly mentioned)
Re: Copy database value in text file [message #214840 is a reply to message #214838] Thu, 18 January 2007 04:35 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
And a note of caution.
UTL_FILE works in serverside. The file will be created in server in a predefined directory.
SQL*PLUS spool works in clientside. You can create it anywhere on the fly.
Re: Copy database value in text file [message #214966 is a reply to message #214823] Thu, 18 January 2007 15:39 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
However spool can't be used in a trigger. It is not a sql command, it is a sql*plus command.
Previous Topic: How to upload data from excel sheet to databasetable
Next Topic: PROBLEM WITH AFTER INSERT TRIGGER (DATA NOT THERE YET!!)
Goto Forum:
  


Current Time: Thu Dec 08 04:12:42 CST 2016

Total time taken to generate the page: 0.05217 seconds