执行过程时pls-00103错误

时间:2015-07-02 07:37:26

标签: sql oracle shell plsql

我正在尝试从shell脚本执行一个过程并最终出错:

请帮助我:

default_shipment_date()
{
log_writer "$pgm_name" "[INFO] $pgm_name - In default_shipment_date Function"
sqlplus -S $CTGAUTH_LOGIN/$CTGAUTH_PWD@$CTGAUTH_TNSNAMES <<-EOF >>  $LOG_DIR/${pgm_name}_${TODAY}.log 2> $LOG_DIR/${pgm_name}_${TODAY}.err

SET SERVEROUTPUT ON
BEGIN
    EXECUTE DEFAULT_SHIPMENT_DATE();
END;
/

exit
EOF
log_writer "$pgm_name" "[INFO] $pgm_name - Exiting default_shipment_date   Function"
}

错误消息显示如下:

Thu Jul  2 03:24:39 EDT 2015) - [INFO] ctg_new_prds - In default_shipment_date Function 
EXECUTE DEFAULT_SHIPMENT_DATE();
        *
ERROR at line 2:
ORA-06550: line 2, column 9:
PLS-00103: Encountered the symbol "DEFAULT_SHIPMENT_DATE" when expecting one  of
the following:
:= . ( @ % ; immediate
The symbol ":=" was substituted for "DEFAULT_SHIPMENT_DATE" to continue.

1 个答案:

答案 0 :(得分:1)

您不需要使用&#34; EXECUTE&#34; PL / SQL中的语句。

如果您需要使用PL / SQL(包括SQL中的上下文切换),那么您的代码应如下所示:

default_shipment_date()
{
log_writer "$pgm_name" "[INFO] $pgm_name - In default_shipment_date Function"
sqlplus -S $CTGAUTH_LOGIN/$CTGAUTH_PWD@$CTGAUTH_TNSNAMES <<-EOF >>  $LOG_DIR/${pgm_name}_${TODAY}.log 2> $LOG_DIR/${pgm_name}_${TODAY}.err

SET SERVEROUTPUT ON
BEGIN
    DEFAULT_SHIPMENT_DATE();
END;
/

exit
EOF
log_writer "$pgm_name" "[INFO] $pgm_name - Exiting default_shipment_date   Function"
}

但是,为什么要切换到PL / SQL,只需从SQL环境执行该过程:

default_shipment_date()
{
log_writer "$pgm_name" "[INFO] $pgm_name - In default_shipment_date Function"
sqlplus -S $CTGAUTH_LOGIN/$CTGAUTH_PWD@$CTGAUTH_TNSNAMES <<-EOF >>  $LOG_DIR/${pgm_name}_${TODAY}.log 2> $LOG_DIR/${pgm_name}_${TODAY}.err

SET SERVEROUTPUT ON
EXECUTE DEFAULT_SHIPMENT_DATE();

exit
EOF
log_writer "$pgm_name" "[INFO] $pgm_name - Exiting default_shipment_date   Function"
}

N.B。假设您的shell脚本都是正确的等等。

希望它有所帮助, 奥利