Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-06-2006
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
UNIX shell scripting for retrieving from oracle

Hello folks,
Please find the below codesample5.sh -> filename)

echo "Selecting dat afrom Cause code"
echo "set appinfo Causecode
$preamble
set serveroutput on size 10000
select * from RMI003_CAUSE_CODE /" | sqlplus -S $username@$hoststring/$password >> test2.dat


When i tried executing the code using "SH" i am getting a file "test2.dat",but the file doesn't have any records. Please suggest me where i am wrong.


Thanks,
Sundar.
Sponsored Links
    #2  
Old 07-06-2006
Dhruva's Avatar
Registered User
 
Join Date: Mar 2006
Location: India
Posts: 255
Thanks: 0
Thanked 1 Time in 1 Post
Try this script

X=`sqlplus -s user/password@host <<eof
set serveroutput on;
set feedback off;
set linesize 1000;
select * from tablename;
EXIT;
eof`

echo $X>testing.dat

Here in X you will get the output and after exiting from sql session put that output in some file.May be this will solve your problem.....
Sponsored Links
    #3  
Old 07-06-2006
Registered User
 
Join Date: Jan 2005
Posts: 683
Thanks: 0
Thanked 4 Times in 4 Posts
Quote:
Originally Posted by sundar_ravi4
select * from RMI003_CAUSE_CODE /" | sqlplus ...[/I]
What is the meaning of the slash character (/)? Its placement is wrong in your code. You either need to put it on a line by itself of replace it with a semicolon ( ; ).
    #4  
Old 07-06-2006
...@...
 
Join Date: Feb 2004
Location: NM
Posts: 9,646
Thanks: 164
Thanked 640 Times in 617 Posts
tmarikle:

Actually old form of Oracle sql statments were in a block ended by a slash. If he added a \n character it would work.

This is legal SQL, try it:

Code:
select 1 from dual
/

Sponsored Links
    #5  
Old 07-06-2006
Dhruva's Avatar
Registered User
 
Join Date: Mar 2006
Location: India
Posts: 255
Thanks: 0
Thanked 1 Time in 1 Post
Yes / is absolutely right but that is required when pl/sql block is used from shell script.here ; would have done the job.
Sponsored Links
    #6  
Old 07-06-2006
Registered User
 
Join Date: Jan 2005
Posts: 683
Thanks: 0
Thanked 4 Times in 4 Posts
Jim,

I must not have been as clear as I thought, that's actually what I was trying to communicate to the OP. I was trying to point it out but also prompt an answer so that perhaps the OP could see his own error. Oh well, perhaps next time I'll be more plain.

Thomas
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
scope of oracle plsql development /unix shell scripting jesthomas Shell Programming and Scripting 2 10-01-2011 12:16 AM
Help needed for shell scripting for oracle. fidelis Shell Programming and Scripting 2 05-25-2010 11:26 AM
Help need urgently for oracle cursors in k shell scripting rajeshorpu Shell Programming and Scripting 4 08-10-2009 11:02 PM
Shell Scripting with Oracle... B14speedfreak Shell Programming and Scripting 2 03-22-2006 11:04 AM
Unix and Oracle scripting Khoomfire Shell Programming and Scripting 7 08-19-2005 06:07 AM



All times are GMT -4. The time now is 11:27 PM.