Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using incremental integer to update variable 1

Status
Not open for further replies.

Wrathchild

Technical User
Aug 24, 2001
303
US
OK, I'm stumped. I have 18 SQL statements in my script and one option will be to run ALL of them. Instead of hardcoding each one to run, I'm trying to loop thru them. Below is what I have. How do I combine $SQL & $i so I end up being able to access the contents of $SQL1, $SQL2, $SQL3...
Code:
SQL1="Select blah blah"
SQL2="Select blah blah"
	i=1
	while [ "$i" -le 18 ]
	do
		SQL=[b]$SQL$i[/b]
                run_sql
		i=$((i+1))
	done

I'm now trying this with an array but having no luck with the syntax of putting an SQL command in an array...I'll focus more on arrays if the above isn't possbile.
 
Have a look at the eval shell builtin:
eval SQL="\$SQL$i"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top