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: I have a SQLPLUS question

Re: I have a SQLPLUS question

From: Kenneth C Stahl <BlueSax_at_Unforgettable.com>
Date: Fri, 15 Oct 1999 07:44:53 -0400
Message-ID: <380713B5.D0EC7231@Unforgettable.com>


You should never call sqlplus directly from the cron. What you really need to do is put the sqlplus invocation inside a shell script and put the shell script on the cron. Like this:

#!/bin/ksh

# Redirect output
exec >/tmp/myscript.log 2>&1

# Set ORACLE_SID and ORACLE_HOME

if [ -z "${ORACLE_SID}" ];then
    export ORACLE_SID=ORCL;
    export ORACLE_HOME=/oracle/app/oracle/product/7.3.4
fi

# Invoke sqlplus
sqlplus -s scott/tiger @/mypath/myscript if [ $? -ne 0 ];then

    print -u2 "Fatal error from sqlplus"     exit 1;
fi
exit 0;

The reason you need to set ORACLE_SID and ORACLE_HOME is that these shell variables are probably set by your .profile and are therefore not set in the default environment that you'll get when you run a job from cron.

GreyWolf_69 wrote:
>
> what is the syntax for calling a sql file from a UNIX command line.
>
> I have a sql script that I want to run from cron, late at night. I
> can't seem to get the syntax correct, between user/password/sid and sql
> file name.
>
> Any help would be great.
>
> Thanks alot.
>
> Wolf
Received on Fri Oct 15 1999 - 06:44:53 CDT

Original text of this message

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