oracle程序错误:遇到符号“procedurename”

时间:2017-01-25 08:10:21

标签: sql oracle procedure

我收到以下错误:

  

PLS-00103:在遇到以下任何一种情况时遇到符号“P_INSERT_STMFRD_REL_RECORDS”:if

任何人都知道我错过了什么?

   PROCEDURE p_insert_stmfrd_rel_records(DeployDate DATE, LogNO NUMBER, InstanceNO NUMBER)

   IS

   begin
    IF EXISTS(SELECT 1 FROM ADM_DEPLOYMENTLOGDETAIL WHERE INSTANCENO = InstanceNO AND LOGNO = LogNO AND DEPLOYDATE IS NOT NULL) THEN
      BEGIN 
        UPDATE ADM_DEPLOYMENTLOGDETAIL SET DEPLOYDATE = DeployDate WHERE INSTANCENO = InstanceNO AND LOGNO = LogNO;
      END;  
    ELSE
      BEGIN
        INSERT INTO ADM_DEPLOYMENTLOGDETAIL(
          DEPLOYDATE,
          STATUSID,
          CANCELEDIND,
          INSTANCENO)
        VALUES(
          DeployDate,
          'D',
          'N',
          InstanceNO);
      END;   


END p_insert_stmfrd_rel_records;    <--- Error occurs on this line.

2 个答案:

答案 0 :(得分:1)

您错过了END IF

此外,您无法以这种方式使用EXISTS;你可能需要:

PROCEDURE p_insert_stmfrd_rel_records(
                                      DeployDate     DATE,
                                      LogNO          NUMBER,
                                      InstanceNO     NUMBER
                                     ) IS
    vNum number;
BEGIN
    select count(1)
    into vNum
    FROM ADM_DEPLOYMENTLOGDETAIL
     WHERE     INSTANCENO = InstanceNO
           AND LOGNO = LogNO
           AND DEPLOYDATE IS NOT NULL;
    IF vNum > 0
    THEN
        BEGIN
            UPDATE ADM_DEPLOYMENTLOGDETAIL
               SET DEPLOYDATE    = DeployDate
             WHERE     INSTANCENO = InstanceNO
                   AND LOGNO = LogNO;
        END;
    ELSE
        BEGIN
            INSERT INTO ADM_DEPLOYMENTLOGDETAIL(
                                                DEPLOYDATE,
                                                STATUSID,
                                                CANCELEDIND,
                                                INSTANCENO
                                               )
                 VALUES (
                         DeployDate,
                         'D',
                         'N',
                         InstanceNO
                        );
        END;
    END IF;
END p_insert_stmfrd_rel_records;

答案 1 :(得分:0)

任何SQL if块的末尾必须有一个END IF;