sql query problem

Hi,

I am passing an argument for the script and that argument values should exist in database.

bill_period_input="'""$1""'"
bill_period=`sqlplus uname/pwd@dbname <<eof!
set verify off
set heading off
set feedback off
select bill_period from bill_period_ref where bill_period=$bill_period_input order by 1;
exit
eof!
`
if [ "$bill_period" = "" ]
then
echo "Enter valid bill period"
exit
fi

but nw i want to change the query to accomodate a where condition as :

select bill_period from bill_period_ref where bill_period like 'G%' order by 1

but when putting the above mentioned where condition in the query not getting the desired result.

Pls describe the problem you are facing !!!

See with below part im validating the argument that it should exists in bill_period_ref table:

bill_period_input="'""$1""'"
bill_period=`sqlplus uname/pwd@dbname <<eof!
set verify off
set heading off
set feedback off
select bill_period from bill_period_ref where bill_period=$bill_period_input order by 1;
exit
eof!
`
if [ "$bill_period" = "" ]
then
echo "Enter valid bill period"
exit
fi

BUt now i want to validate that the argument passed should exists in bill_period_ref table plus its name should also starts with G so for that i want to use this query:

select bill_period from bill_period_ref where bill_period like 'G%' order by

But when im putting this query in the above code, the code is accepting all bill_period what all are there in bill_period_ref table so not at all validating for the bill_period who doesnt start with G.

Thanks

bill_period_input="'G""$1""'"
bill_period=`sqlplus uname/pwd@dbname <<eof!
set verify off
set heading off
set feedback off
select bill_period from bill_period_ref where bill_period=$bill_period_input order by 1;
exit
eof!
`
if [ "$bill_period" = "" ]
then
echo "Enter valid bill period"
exit
fi

or

bill_period_input="'G%""$1""%'"
bill_period=`sqlplus uname/pwd@dbname <<eof!
set verify off
set heading off
set feedback off
select bill_period from bill_period_ref where bill_period like $bill_period_input order by 1;
exit
eof!
`
if [ "$bill_period" = "" ]
then
echo "Enter valid bill period"
exit
fi

Its not working.

And i think instead of hardcoding G its better to take values from table itself as if in future different bill_periods's are required then it will b easy to change the qry thtz it.

And o/p of
select bill_period from bill_period_ref where bill_period like 'G%' order by 1 is:

G03
G08
G13
and so on..