Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Exiting a Shell Script based on results of SELECT

Re: Exiting a Shell Script based on results of SELECT

From: Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl>
Date: Thu, 27 Aug 1998 21:45:05 +0200
Message-ID: <6s4cuf$3fs$1@pascal.a2000.nl>


>I have a shell script which runs overnight which calls several other
scripts.
>In between, I want to check # of records from a table

In count.sql:

    set heading off
    set feedback off
    select count(*)
    from my_table;
    exit

In your Unix shell script (no errorhandling, like Oracle not being available...):

    result = $( sqlplus -silent scott/tiger @count.sql )     echo "${result} row(s)"
    # exit if result less than 10:
    if test ${result} -lt 10
    then

      echo "Too few rows"
      exit 1

    fi
    # continue here...

Arjan. Received on Thu Aug 27 1998 - 14:45:05 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US