Assign the return value of the SQL to a variable in UNIX

Hi

I am new to UNIX. I am trying the below and getting the error.

I am trying to assign the variable with the value of the query result. I want this value to use in the next steps.

Created UNIX file (Batch.sh) as below

#!/bin/ksh
sqlplus callidus/callidus4u@attstcal @Batch.sql

Created UNIX file (Batch.sql) as below

batchname = ~sqlplus -s callidus/callidus@attstcal <<EOC
select batchname from cs_table where rownum = 1 order by 1 desc;
EOF!
)
echo $batchname

I am getting the below error

"SP2-0734: unknown command beginning "batchname=" - rest of line ignored.

Can anyone please help.

Please use code tags as required by forum rules!

I can't follow what you are doing there. Batch.sql seems to be run from within sqlplus, so it should not contain any shell commands/constructs, only sqlplus code. Plus, your here document seems broken (the delimiter does not match the word). Plus, there's an unmatched closing parethesis.

If I update the files as below, will this resolve the issue.

Batch.sh:

#!/bin/ksh
sqlplus callidus/callidus4u@attstcal @Batch.sql
echo $batchname

Batch.sql:

batchname = ~sqlplus -s callidus/callidus@attstcal <<EOC
select batchname from cs_table where rownum = 1 order by 1 desc;
EOF~
)