How to write a shell script to retrieve datas from database after that this database are redirect to a excell sheet and then i got a mail that gives details about the database with the column name and data..
Get your data by calling appropriate SQL queries like SELECT etc. maybe via SQLPLUS and redirect it to someoutput file. As output delimeter you might want to choose something appropriate, maybe a semicolon, depending to your data so that it can be imported as let's say .csv file.
How to check for return codes of commands and how to send a notify mail is covered in plenty posts in this forum.