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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

repeated inputs within functions

Status
Not open for further replies.

unixnovice

Technical User
Sep 26, 2002
2
US
Hi

Can you advise me of the following :-
I have written a function to accept 2 variables, & pass them into an SQL select, as follows : -

function display_accounts_users
{
clear
print "\n\nDisplay Accounts & Users"
print -- "-------------------------"
print -n "\nPlease enter Account No. (q to quit): "
read acct_no
if [[ -z $acct_no || $acct_no = q || $acct_no = Q ]]
then
return
fi
print "\n"
print -n "\nPlease enter User ID (q to quit): "
read id_user
if [[ -z $id_user || $id_user = q || $id_user = Q ]]
then
return
fi

isql -Ubluat -Ppassword -S$AR_ENV_SYB_SERV_NAME << !
select acct_no, id_user from t_user
where id_user = &quot;$id_user&quot;
and id_acct = &quot;$acct_no&quot;
go
!
}

I wish to enhance the function to allow the user to prompt for the User ID (read id_user)
a 2nd & subsequent time, performing the SQL, until &quot;q&quot; is entered, when my function will end.
I am relatively new to UNIX, and cannot find entries in our reference books to describe how this might be achieved.

I know I could do a
while read x
do
etc etc
done < filename
but how do I get all my “read id_user”s, excluding the q, into filename ?

Hope you can help.
Best Wishes
 
Put it in a different &quot;while loop&quot;

while :
do
read x
if [ &quot;$x&quot; = &quot;q&quot; then
break
fi
etc...
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top