PLSQL语法错误

时间:2016-02-16 14:06:25

标签: oracle plsql

这是我第一次使用PL / SQL。我在下面的UPDATE语句中收到错误。虽然我认为UPDATE语句没有问题,而是IF条件,就在UPDATE语句之上。我在SQL Developer中遇到的错误是:"Error(20,5): PLS-00103: Encountered the symbol "UPDATE" when expecting one of the following: . ( * @ % & - + / at mod remainder rem then <an exponent (**)> and or || multiset The symbol "then" was substituted for "UPDATE" to continue."

基本上我想做的就是:

if(current_pwd != oldUserPwd1 || current_pwd != oldUserPwd2) {
   Make the update ...
}

任何人都可以帮助我吗?感谢

   CREATE OR REPLACE PROCEDURE SUPDATEWORD(
   current_pwd Users.Password%TYPE,
   current_uid Users.UID%TYPE   
)
is
  oldUserPwd1 VARCHAR(255);
  oldUserPwd2 VARCHAR(255);
BEGIN  
  SELECT X1.PASS1
  INTO oldUserPwd1 
  FROM OLDUSERPASSWORDS x1
  WHERE current_uid = x1.UID;

  SELECT X2.PASS2
  INTO oldUserPwd2 
  FROM OLDUSERPASSWORDS x2
  WHERE current_uid = x2.UID;

  IF current_pwd <> oldUserPwd1 OR current_pwd <> oldUserPwd2
    UPDATE ISOUSERS SET Password = current_pwd; 
    UPDATE OLDUSERPASSWORDS SET PASS1 = current_pwd AND PASS2 = oldUserPwd1 AND DATELASTCHANGE = SYSDATE;
  ELSE
    RAISE_APPLICATION_ERROR(-20000, 'This exception means success');
  END IF;

END SPUPDATEPASSWORD;

2 个答案:

答案 0 :(得分:3)

您遗失THEN

IF current_pwd <> oldUserPwd1 OR current_pwd <> oldUserPwd2 THEN

答案 1 :(得分:1)

OR

if current_pwd != oldUserPwd1 or current_pwd != oldUserPwd2 then
   Make the update ...
end if;