How to handle the Multiple Rows in the Database


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to handle the Multiple Rows in the Database
# 1  
Old 03-05-2007
Bug 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
# 2  
Old 03-05-2007
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

# 3  
Old 03-05-2007
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 ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How does extundelete handle multiple versions of the same inode?

Hi, I noticed a weird behavior in extundelete way to choose the filename to which it will restore a given inode. Here is an example : root@rescue:~# for after in '' 0 740 741 $(date -d 'now - 1 year' +%s); do rm -rf RECOVERED_FILES/; echo -e "$(date -d@$after 2> /dev/null || echo No... (4 Replies)
Discussion started by: chebarbudo
4 Replies

2. Shell Programming and Scripting

How to print multiple rows from database query?

HI, I am having scenario like to print multipule rows from output of database query sample query i mentioned below code=`db2 -x select code,values from dummy` in the query output i am getting around 110 records with 2 columns. sample output pasted below code,value... (3 Replies)
Discussion started by: bhaskar v
3 Replies

3. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

4. Shell Programming and Scripting

Split single rows to multiple rows ..

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies

5. UNIX for Dummies Questions & Answers

how to handle multiple apps on host?

So, I'm going to install Oracle DB within my Suse host... Also, I would like to run Virtual Box and Tomcat.. ok, tomcat is going to be runnable app that will start at boot.. but, how to handle Oracle and virtual box? I would like to have an Oracle under it's own user, and to be able to use... (0 Replies)
Discussion started by: bongo
0 Replies

6. UNIX for Dummies Questions & Answers

Converting rows into multiple-rows

Hi every one; I have a file with 22 rows and 13 columns which includes floating numbers. I want to parse the file so that every five columns in the row would be a new record (row). For example, the first line in the old file should be converted into three lines with first two lines contain 5... (6 Replies)
Discussion started by: PHL
6 Replies

7. Shell Programming and Scripting

Database handle to a child script using exec

Hello, Can I pass a database handle created in parent script to a child script triggered using exec ?? Parent script ========= $dbh =DBI->connect{......); # Db handle creation $param1 =10; # parameter one exec "childscript.pl $param1 $dbh "; # executing childscript.pl with two parameters... (0 Replies)
Discussion started by: coolbhai
0 Replies

8. Shell Programming and Scripting

extract multiple cloumns from multiple files; skip rows and include filenames; awk

Hello, I am trying to write a bash shell script that does the following: 1.Finds all *.txt files within my directory of interest 2. reads each of the files (25 files) one by one (tab-delimited format and have the same data format) 3. skips the first 10 rows of the file 4. extracts and... (4 Replies)
Discussion started by: manishabh
4 Replies

9. Shell Programming and Scripting

How to handle multiple rows in a file

I have a FILE a.txt which has the following data 113901.94,113901.94,56950.97,56950.97,NOT MATCHING,NOT MATCHING 10693.04,10693.04,5346.52,5346.52,NOT MATCHING,NOT MATCHING 1901.94,1901.94,550.97,550.97,NOT MATCHING,NOT MATCHING 103.04,103.04,53.52,53.52,NOT MATCHING,NOT MATCHING #### This... (2 Replies)
Discussion started by: ksmbabu
2 Replies

10. Shell Programming and Scripting

Handle Configuration File with same name of Parameter in multiple Sections

Hi I have a config file with multiple section and a parameter with the same name in each section. I need to read each parameter for distinct section. Parameter = 1 .... Parameter = 2 .... Parameter = 4 .... Tried this: grep -m1 '^*ProcessorsNumber' ServiceBrokerFramework.cfg |... (7 Replies)
Discussion started by: potro
7 Replies
Login or Register to Ask a Question