How to assign record count output of isql to a shell variable ?

isql
select count(*) from Table
eof

How to assign record count output of isql query to a shell variable ?

variable=`isql << eof
select count(*) from Table
eof`

Actually with this option, the variable gets the value like '(1 row affected)' or '(0 rows affected)'. But i need only the exact record count. How to achieve this..?

In version 11.0.x and higher, specify "set nocount on" option to suppress the rows affected line.

In pre 11 versions, use sed to delete the lines that have the word "affected" in them.

tyler_durden

1 Like

Is there any option like ,
establishing isql connection only once, and executing multiple queries and getting their respective record counts in separate variables...?

My need is like,
isql >>
recordcount1= query1
recordcount2= query2
>>