Take Data From a table and send it through mail

Hi can anyone help me in writing a code for taking data from a table and need to send that data through mail using mail -x command..

Table you mean from Data Base ? If so , is it from which DB?

I am assuming that the table exists in Oracle, you can do:

(1) Connect to oracle DB, using sqlplus -s "user\_name/passwd"@oracle_sid <<
write your query here to get the data
(2) store the step(1) output into a file
(3) mail the file using mail -x from the file obtained in step :(2)

Regards,

Thanks

How to store the output into a file .I am using oracle DB

I need to select 9 columns

---------- Post updated at 08:07 AM ---------- Previous update was at 06:22 AM ----------

Thanks

How to store the output into a file .I am using oracle DB

I need to select 9 columns

SQL*Plus command SPOOL can be used to store query result in file.

Syntax:

SPOOL filename
--your query here
SPOOL OFF

Note: Search the internet and you will find many examples of spooling along with how to format query results.