Return value inside isql to a shell variable in ksh

Hello,
I have a shell script where I am doing an isql to select some records. the result i get from the select statement is directed to an output file. I want to assign the result to a Shell variable so that I can use the retrieved in another routine.
e.g.
"isql -U${USER} -P${PASSWD} -S${SERVER} -D${DBNAME}" <<EOF>> output1

select Names from Book

... some error check from the result above...
declare @CustID varchar (50)
select @CustID = Customer ID from Customer

EOF

The CustomerID I retrieved above needs to be passed to a UNIX variable so that I can use it further down after the end of the isql.

I did look at some threads where this was questioned but most of the answers are to retreive the value from selects when doing the isql... such as
SOMEVARIABLE = `isql....

however in the above case the result from the first select would also be passed to SOMEVARIABLE... and if so then how would u extract the values that are specifically needed.

Any ideas would be much appreciated.

Thanks.

Well, isql talks to stdout, so write a script in isql using SQL SELECT or PRINT if available, process stdout with something like sed to extract it, and run it. Usualy isql has too much junk around the data to allow you to execute isql output without cleaning. Write what you toss in the log or stderr so you can see error messages.