?
Solved

retrieving data from oracle to flat file

Posted on 2001-08-22
3
Medium Priority
?
316 Views
Last Modified: 2010-04-21
Hi,

I am new to unix and would like to write a script that would allow me to extract 2 fields from an oracle database and write them out to a flat file.
Could someone point me in the right direction.

Thanks
0
Comment
Question by:HabBoy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Accepted Solution

by:
bira earned 400 total points
ID: 6414680
Hi
  A little example here:

sqlplus user/password  <<fim
SET HEADING OFF
spool flat.txt
select tablespace_name from user_tablespaces ;
spool off
fim


  Save the above script, chmod it 777 and run it as
an oracle user.

   This will create the file named flat.txt  with the
result of the select.

     Regards
0
 
LVL 1

Expert Comment

by:hakula
ID: 6458487
You may use SQL*Plus concatenation "||". You'd better set feedback off also.

#!/bin/sh
sqlplus scott/tiger 2>/dev/null <<EOC
set heading off feed off term off

spool flat.txt
select ename || '|' || job || '|'
from emp;
spool off
quit
EOC

# flat.txt lists ename and job, delimited by "|".
# Each line is terminated by "|". You may
# use Unix utilities such as sed, awk to process it

Regards.
0
 

Author Comment

by:HabBoy
ID: 6480539
Thanks bira.

Habboy
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question