Fetching CLOB value from oracle into shell script

Hi,

Can anybody let me know how i can achieve the below output.

I have a select query which selects two columns. I need to spool the value into a dat file for each row that is returned from the query with the coulumn1 as the name of the dat file .

ex:
column1: location_id
column2: text value

output dat file:

<location_id>.dat with value from column2.

spool output.dat
select column1, column2 from table;
spool off

tyler_durden