query to get a value from database

Hi friends,

I have written a script which retrieves one value from the database.
It takes time for the sql query to get the desired output. So the query runs fine from TOAD or from UNIX console.

However if I put this in a script it doesn't work. The script is as below.

#! /bin/ksh
DB_VALID_CDR=`sqlplus -s username/password<<!EOF | grep -v "^Connected" 2>&1
set termout off echo off feedback off pause off timing off time off
set pages 0
clear breaks
clear compute
set termout on
select a.VALUE_INTEGER from client_statistics a, statistic_type b where a.STATISTICS_TYPE=b.Statistic_type_id and a.STATISTICS_OBJECT like '%20071217102445_9673324_AG40_20071217101738_0000002118%' and b.STATISTIC_TYPE='valid_cdrs'
EXIT
!EOF`
echo $DB_VALID_CDR

I strongly believe that the issue is with the query taking time to return the value.

Please let me know how to tackle the issue.

Many thanks

Hi Vivek

You forgot to put the semicolon (:wink: at the end of the query, that's why your query is not executed.

Regards

Erwin

Many thanks ermur....now its working

Cheers mate!!!