The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
rsh script with inside a for loop trekianov Shell Programming and Scripting 5 12-06-2008 12:39 PM
Connecting to Oracle Database dreams5617 Shell Programming and Scripting 4 05-02-2008 12:37 PM
remsh inside of while loop joettacm UNIX for Advanced & Expert Users 1 12-07-2007 12:54 PM
read inside a while loop dta4316 UNIX for Dummies Questions & Answers 3 05-21-2005 10:53 AM
Connecting to a Oracle Db using SunOS darmat0712 UNIX for Dummies Questions & Answers 2 03-03-2005 01:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-12-2008
Devesh5683 Devesh5683 is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 5
Error connecting oracle from inside while loop

Hi,

I m trying to connect oracle database from inside while loop.
I m trying to put the output of sql query in a flat file.
Anyone please help me out.

cat $FILE_NAME | \
while read da_name
do

$ORACLE_HOME/bin/sqlplus -s user_name/password@instance << EOF >> $OUTPUT_FILE

select global_name from global_name;

EOF
done

Getting output as output.

thanks in advance
  #2 (permalink)  
Old 05-12-2008
hanu_oracle hanu_oracle is offline
Registered User
  
 

Join Date: Mar 2008
Location: MUMBAI, INDIA
Posts: 41
Quote:
Originally Posted by Devesh5683 View Post
Hi,

I m trying to connect oracle database from inside while loop.
I m trying to put the output of sql query in a flat file.
Anyone please help me out.

cat $FILE_NAME | \
while read da_name
do

$ORACLE_HOME/bin/sqlplus -s user_name/password@instance << EOF >> $OUTPUT_FILE

select global_name from global_name;

EOF
done

Getting output as output.

thanks in advance
###############################

while read da_name
do


RETVAL=`sqlplus -l user_name/password@instance <<EOF

insert into ODS_T_CFS_DUMP(FILE_NAME, REGION_ID, SDP_ID, SEQUENCE_ID, TOTAL_RECORDS) values ('$file','$region_id','$sdp_id','$sequence_id', '$sub_records');

EXIT
EOF`

done


Here you can get the SQL-Query output in the RETVAL Variable.
You can use this $RETVAL valve anywhere in the script.

#####################################

Last edited by hanu_oracle; 05-12-2008 at 09:49 AM.. Reason: Take SQL-Query output in the variable
  #3 (permalink)  
Old 05-12-2008
Santdash Santdash is offline
Registered User
  
 

Join Date: May 2008
Location: Bangalore(native Orissa)
Posts: 3
Hi,

You Can Use Following shell Script instead for database connection and pulling all the details into flat file.

echo "set time off;" > cpled_wkrep.sql
echo "set timing off;" >> cpled_wkrep.sql
echo "set pagesize 0;" >> cpled_wkrep.sql
echo "set linesize 1300;" >> cpled_wkrep.sql
echo "set trimspool on;" >> cpled_wkrep.sql
echo "set heading off;" >> cpled_wkrep.sql
echo "set echo off;" >> cpled_wkrep.sql
echo "set verify off;" >> cpled_wkrep.sql
echo "set termout off;" >> cpled_wkrep.sql
echo "set feedback off;" >> cpled_wkrep.sql
echo "" >> cpled_wkrep.sql
echo "spool VVMFNAMES;" >> cpled_wkrep.sql
echo "" >> cpled_wkrep.sql
echo "select V_VMF_CODE||'|'||V_VMF_NAME||'|'||V_VMF_BUS_STAT||'|' from V_VMF_CLASS where V_VM
F_BUS_STAT = 'SUPPORTED' order by V_VMF_CODE;" >> cpled_wkrep.sql
echo "" >> cpled_wkrep.sql
echo "" >> cpled_wkrep.sql
echo "spool off;" >> cpled_wkrep.sql
echo "exit;" >> cpled_wkrep.sql

sqlplus username/password@instance @cpled_wkrep.sql
rm -rf cpled_wkrep.sql


OutPut Will be in the file VVMFNAMES.lst
  #4 (permalink)  
Old 05-13-2008
Devesh5683 Devesh5683 is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 5
Smile

thanks for the help
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0