Home » SQL & PL/SQL » SQL & PL/SQL » write the query result in file and send the file in email attachement. (oracle 9i)
write the query result in file and send the file in email attachement. [message #357174] Tue, 04 November 2008 03:45 Go to next message
kashifchughtai
Messages: 125
Registered: October 2007
Senior Member
Can anybody tell me How to write the query result in the file and send the file in email attachement using plsql.?
Re: write the query result in file and send the file in email attachement. [message #357176 is a reply to message #357174] Tue, 04 November 2008 03:54 Go to previous messageGo to next message
Olivia
Messages: 519
Registered: June 2008
Senior Member
The simplest way is via SQL*Plus in three steps:
1. spool (give a valid path and filename)
2. Run sql
3. spool off

If you want to use PL\SQL, the package that has the procedures you need is utl_file. Use UTL_SMTP package for sending mail


Regards,
Oli



[Updated on: Tue, 04 November 2008 03:56]

Report message to a moderator

Re: write the query result in file and send the file in email attachement. [message #357178 is a reply to message #357176] Tue, 04 November 2008 03:58 Go to previous messageGo to next message
kashifchughtai
Messages: 125
Registered: October 2007
Senior Member
Actualy i need to run a job that will create a file daily n send it in attachement. right now i am sending the results in html format but now i want it to be sent in attachment(csv format)
Re: write the query result in file and send the file in email attachement. [message #357183 is a reply to message #357178] Tue, 04 November 2008 04:17 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Use UTL_FILE to write the results of the query out to a file.
Then use UTL_SMTP to email this attachment to yourdestination
Previous Topic: Oracle error
Next Topic: updating table data between databases (2 threads merged by bb)
Goto Forum:
  


Current Time: Sun Dec 08 06:57:48 CST 2024