执行PL / SQL条件语句时发出问题

时间:2017-07-28 08:43:41

标签: sql oracle plsql

当我尝试根据另一个表列值更新几个表空间时,我面临以下问题。

PL / SQL查询:

DECLARE
   buildVal NUMBER;
BEGIN
    SELECT BUILDVERSION 
    INTO buildVal 
    FROM WCSDBA.BUILDDETAILS
    WHERE BUILDID =1;
    IF (buildVal = 0) THEN 
        UPDATE WCSDBA.BUILDDETAILS 
            set BUILDVERSION = 1, 
                BUILDDESCRIPTION = 'FirstVersion' 
            WHERE BUILDID =1;
        commit;
    END IF;
END;

例外:

Query failed because: 
ORA-06550: line 9, column 3: 
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ; The symbol ";" was substituted for "end-of-file" to continue.

对同一

的任何帮助或建议

1 个答案:

答案 0 :(得分:1)

DECLARE
   buildVal NUMBER;
BEGIN
   SELECT BUILDVERSION INTO buildVal FROM WCSDBA.BUILDDETAILS WHERE BUILDID =1;
    IF (buildVal = 0) THEN 
        UPDATE WCSDBA.student set stVersion =1;
        UPDATE WCSDBA.BUILDDETAILS set BUILDVERSION = 1, BUILDDESCRIPTION = 'FirstVersion' WHERE BUILDID =1; --in this line
        commit;
    END IF; -- here
END;

请尝试这一个,您忘记END IF之后的分号,并将更新列分隔为and而不是逗号