Generating & executing the SELECT and UPDATE clause dynamically using shell script

Hi All,

I need to write one shell script. The requirement is as follows.

a) I am having list the employee names in a file stored in /tmp directory location as below
/tmp/emp.txt

b) and the contents are as below
cat emp.txt
ravi
raj
ram
arun

c) I need to connect to sybase database (assume the name of the database is textbt)

d) Then i need to execute the following select query in that database
select status, emp_name from emp where emp_name in (<these names will have to come from that unix file /tmp/emp.txt)
i mean the where clause will have to contain like this
where emp_name in ('ravi','raj','ram','arun')

e) If the status value is "A" (active), only then it will have to be updated as "I" (In active) for the respective emp names.
i.e) One update query will also have to be generated dynamically and executed as below.

assume, the status is "A" for only the emp names ravi and ram
then the update query should be like the below

update emp set status = 'I' where emp_name in ('ravi','ram')

Please could you help me in providing some ideas. Thanks in advance.

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.