I want to fetch the record from oracle database in oracle procedure and develop a shell script to call oracle procedure and convert fetched data in .dat file how would i achieve it.
Asked
Active
Viewed 560 times
-2
-
5What have you done so far? Any error you are getting? – Nitish Mar 27 '17 at 05:39
-
Let me get this straight. You want a oracle procedure to to get certain values from a table, then create a shell script using this data and the shell script should convert data in a .dat file? – Mar 27 '17 at 07:32
-
@Gerry Yes you got me right. Actually i am new to this so i havent tried yet.but wanted proper direction to do it. – AspiringDeveloper Mar 27 '17 at 10:55
-
it will be best if you use an external language like perl. you can use dbms_scheduler to kick of the script and the perl script can do all the work. You can however issue the scheduler to kick of a shell script directly, but perl will be easier and more robust. – Mar 27 '17 at 11:02
1 Answers
0
Shell script can't connect to database itself. Some ways to do it:
- call
sqlplus
in a shell script using spool option. There are question on SO about this subject, for example: How to create a oracle sql script spool file - Use UTL_FILE to write to disk from Oracle directly, without shell script.
- Use another language to connect to oracle and read data and write it to a file(java, python, etc.)

Community
- 1
- 1

Florin Ghita
- 17,525
- 6
- 57
- 76