The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to handle multiple rows in a file ksmbabu Shell Programming and Scripting 2 05-14-2008 09:44 PM
flexible sed command needed to handle multiple input types SiftinDotCom Shell Programming and Scripting 2 03-19-2008 12:39 PM
Handle Configuration File with same name of Parameter in multiple Sections potro Shell Programming and Scripting 7 03-05-2008 07:36 AM
a bit tricky to change it multiple rows in one row and ... netbanker Shell Programming and Scripting 2 12-31-2007 09:48 PM
Output Multiple Field from dataBase file Dennz UNIX for Dummies Questions & Answers 3 09-01-2003 09:41 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-05-2007
Registered User
 

Join Date: Feb 2007
Location: Chennai
Posts: 8
Smile How to handle the Multiple Rows in the Database

Hi All,

I have problem with database validations, actually my requirement is, my code will generate some seqno;s, which i have to check in database, whether the generated seqno;s are present in database or not, if the generated seqno;s are present in the database means, i need to generate new seqno;s skipping the found seqno;s in database, for this i have written code

Code:
	p_no_seqno=5
	tempa=1
	p_seqno=232123210123
	while [ $tempa -le $p_no_seqno ]
	do
		p_seqno=`expr $p_seqno + 1`
		if [ $tempa -lt $p_no_barcode ]; then
		d_seqno="${d_seqno}${p_seqno}",""
		else
		d_seqno="${d_seqno}${p_seqno}"
		fi
		tempa=`expr $tempa + 1`
	done

	barc=`sqlplus -s scott/tiger << EOF
	WHENEVER SQLERROR EXIT 1
	SET FEEDBACK OFF VERIFY OFF HEAD OFF ECHO OFF
	SET SERVEROUTPUT OFF TIMING OFF
	SET PAGES 0
	select seq_no from temp where seq_no in ($d_seqno);
	exit
	EOF`
	echo $barc
The Output for this will be
If only one seqno or no seqno found in database means,
No errors are displaying and the scripting is running fine

If more than one seqno found in database means,
It is showing the following error
seq_no.ksh[56]: test: 0403-004 Specify a parameter with this command


I tried store the values in a text file, but i am unable to retrieve the stored values by using the following code

Code:
	echo $barc > testing.txt
The output of the testing.txt file when more records are there is
121313123123 123123123123 2342342342342


How to split the seqno;s and assign them to a array or variable


Thanks in Advance
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-05-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Quote:
seq_no.ksh[56]: test: 0403-004 Specify a parameter with this command
One of the variable in test command has null value

Quote:
How to split the seqno;s and assign them to a array or variable
Code:
index=0
for str in $barc 
do
 arr[$index]=$str
 (( index=index+1 ))
done
Reply With Quote
  #3 (permalink)  
Old 03-05-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,453
Quote:
seq_no.ksh[56]: test: 0403-004 Specify a parameter with this command
Code:
if [ $tempa -lt $p_no_barcode ]; then
		d_seqno="${d_seqno}${p_seqno}",""

Does the variable p_no_barcode has a value or is it null ?
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0