Exiting out of the script

I have to write a script in ksh which again should call another script. Say A.ksh is calling B.ksh. Now in B.ksh if the condition we are checking for is true then we have to go back to the main script A.ksh or if the condition in B.ksh is false then we have to totally come out of the scripts.
I have written a sample code and trying to achive the functionality mentioned above. In case of successs i was able to come back to the main script but even in case of failure it is coming back to main script A.ksh which is not wanted. Below are the sample scripts i am working on.

A.ksh

while [ 1 ]
do
for file in `ls /home/inputfile/*.dat`
do
        tc=/home/oracle/db.log
        string=`sqlplus user/pass <<EOF >$tc
        set serveroutput on;
        select 'DATABASE IS UP' from dual;
        exit;
        EOF`
        if grep 'DATABASE IS UP' $tc; then
            cd /home/oracle/test/
            ./echoing.ksh
        else
            echo "db is down"
        fi
done
sleep 5
done 

B.ksh

echo "db is up so came into new script"
if grep 'error files' /home/oracle/db.log; then
    echo "file has the word wanted to check for"
    echo "now the script should go back to main script"
    sleep 5
    cd /home/oracle/test/
    ./ods.ksh
else
    echo "error hence coming out"
fi

I missed the line where A.ksh is calling B.ksh, so here's how...

Have A.ksh add these lines:


B.ksh

if [[ $? -ne 0 ]]; then
  exit 1
fi

and B.ksh has:


if [[ $some_condition_fails -eq 1 ]]; then
  exit 1
else
  exit 0
fi

ta da.
echo "db is up so came into new script"
if grep 'error files' /home/oracle/db.log; then
echo "file has the word wanted to check for"
echo "now the script should go back to main script"
sleep 5
cd /home/oracle/test/
./ods.ksh
else
echo "error hence coming out"
fi