-
Dumping into Txt files
Hi all,
I'm stuck up in a situation here. I need to extract two columns, say Col1 and Col2 and dump them into text files depending upon Col1. Every item (distinct row) of Col1 item should be dumped into one text file, so, i will end up with a text file for each Col1 item. I tried with Sqlplus Spool but couldn't get through. Could anybody suggest any other options available in Oracle 10gr2? I am on Fedora 10gR2. I use Sqltools as sql editor.
Thank you all for your time and consideration.
gtcol
Last edited by gtcol; 12-21-2007 at 03:41 AM.
-
-
Assuming we work on scott.emp and COL1 is mgr COL2 is ename you could use
Code:
set heading off
set feedback off
set pagesize 0
spool s.sql
select distinct 'spool file_'||mgr||'.txt'||chr(10)||chr(13)||' select mgr,ename from scott.emp where mgr='''||mgr||''';'||chr(10)||chr(13)||' spool off' from scott.emp
/
spool off
@s
Regards
-
Thank you Davey/Bore for your prompt responses,
I had thought about Utl_File but I was thinking about doing it through sql, as Bore has suggested. Bore's script has given me what I actually wanted.
Thank you Bore/Davey once again.
gtcol
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|