Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 29th, 2010, 06:45 AM
anil029 anil029 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 4 anil029 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 54 m 18 sec
Reputation Power: 0
Calling sql file from shell script with parameters.

Hi,
I am calling a sql file script.sql from shell script and passing few parameters also as shown below:

Code:
sqlplus -S  id/password @script.sql  $param1 $param2 


Now,In sql file I have to create a extract text file after querying oracle tables based on the parameters passed(param1,param2) as shown below:

Code:
SPOOL  a.txt

SELECT col1,col2,col3,……..coln
FROM table
where col1 ='&1' and col2=`&2’;
/
SPOOL OFF


This may contain thousand of rows. The extract file will contain data row by row and each column value will be separated with a tab space. I am using SPOOL to this but the extract file is giving me values of single row in multiple rows and the passed parameter values (param1 & param2) are also getting printed in the extract file at the top with old and new labels, which I don’t want to be present in my extract file. I just want the data rows in my extract file separated by tab.
I also want some status code to be returned back to my shell script which will determine whether the sql file is successfully executed or not based on which error message will be sent vail email.

Please help me with the sample examples to resolve this problem.

Thanks in advance.

Regards,
Anil

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Calling sql file from shell script with parameters.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap