How to get the output of a ISQL command in a variable?

I am trying to run a query which returns a sum value(a number).
I want to get it in a variable so that i can refer to that variable in different places.
when i am running the following command

  variable=`isql -Uuser -Sserver -Ppassword
1> select sum(count(*)) from xyz..abc where clm_id in(43517830,80226100,340223200,70217600,400222400,720221500,920220600,970226100,990223800) group by clm_id
2> go`

The output of the variable comes as below

 ksh[4]: 0403-057 Syntax error: `(' is not expected. 

while i am expecting output as 58.

what should i do please suggest.

Thanks

Maybe saying more about your system (OS + version and shell you use) may help us understand...
ksh standard syntax for giving values to a variable which comes from some sort of command execution is:

 VAR=$( command...) 

and so using "(" etc will be interpreted by the shell...

1 Like

Ive got a feeling your attempt will not work also because not on one line only...

I would suggest you to use in your script a heredoc which calls sql...

This is what I do with SQL (oracle) for example:

your_script
.
.
# call your sqlcode
sqlplus -silent user/passwd <<END
start $HOME/test.sql
exit;
END

# continue with your script
.
.