How to write Flat Files by shell script using Oracle Database

Hello There..

I came to a situation where I need to write flat files using shell scripts, I need to pull the records from the oracle database and create the flat file, This process should be automated.

Can any shell script expert out here to help me.. please..

Will be really glad to see your response.

Thanks in advance.
BCool

using these forums' search capabilities would be a good start!

Start by searching for sqlplus.

Howz bouts thiz
(1) Write a SQL script to spool data to a file
(2) Write UNIX script to invoke SQL script

Example:
(1)
/*
This is SQL script named: get_emp.sql
*/
spool ascii.txt
Select * from emp;
spool off
(2)
#!/bin/sh
#
# This is UNIX script named: cron.job
# Runs SQL script and e-mail result to users
#
sqlplus uid/pwd @get_emp.sql

mail 'outlook Address list' < ascii.txt