-1

This is my first time using PL/SQL. I am getting an error on the UPDATE statement below. Though I don't think there is something wrong with the UPDATE statement, but rather the IF condition, that is just above the UPDATE statement. The error I'm getting in SQL Developer, says: "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."

So basically what I want to do is this:

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

Can anyone help me out? Thanks

   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
  • Aside from the syntax error (in answer below), you should really consider storing HASH values rather than the passwords directly. A web search will reveal many, many articles about why you don't want to store passwords directly in databases.
    – SlimsGhost
    Feb 16, 2016 at 14:09
  • I am already storing the hash, and not password in clear text :-)
    – MOR_SNOW
    Feb 16, 2016 at 14:39

2 Answers 2

3

You are missing THEN:

IF current_pwd <> oldUserPwd1 OR current_pwd <> oldUserPwd2 THEN
1

OR

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.