我在下面的代码中收到错误。我添加了一个问题所在的恐怖<------
。
错误消息表明需要THEN
,但当我使用THEN
时,则表示预计会BEGIN
。
Error(27,6): PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: then and or The symbol "then" was substituted for "BEGIN" to continue.
Error(30,6): PLS-00103: Encountered the symbol "END" when expecting one of the following: , ; return returning
我做错了什么?
感谢您的帮助
create or replace PROCEDURE "sp_updateUserPassword"(newUserPwd IN VARCHAR2, curIsoUserUID IN NUMBER)
IS
curUserID NUMBER;
userDateCreated DATE;
oldUserPwd VARCHAR2(255);
BEGIN
SELECT ISOUID INTO curUserID FROM ISOUSERS WHERE ISOUID=curIsoUserUID;
SELECT DATECREATE INTO userDateCreated FROM ISOUSERS WHERE ISOUID=curIsoUserUID;
SELECT PASSWORD INTO oldUserPwd FROM ISOUSERS WHERE ISOUID=curIsoUserUID;
IF(newUserPwd = oldUserPwd)
THEN
raise_application_error(-20000, 'The new password must be different from the previous password');
RETURN;
END IF;
IF NOT EXISTS
(
SELECT ISOUID
FROM OLDUSERPASSWORDS
WHERE ISOUID=curIsoUserUID
)
BEGIN <------------ Error is here
INSERT INTO OLDUSERPASSWORDS(ISOUID, DATECREATE, DATELASTCHANGE, CURRENTPASS, OLDPASS)
VALUES(curUserID, userDateCreated, SYSDATE, newUserPwd, oldUserPwd)
END;
/*raise_application_error(-20000, 'TEST');*/
END "sp_updateUserPassword";
--------------------------更新-------------------- ------------
更正了代码,现在看起来像这样:
IF NOT EXISTS
(
SELECT ISOUID
FROM OLDUSERPASSWORDS
WHERE ISOUID=curIsoUserUID
)
THEN
BEGIN
INSERT INTO OLDUSERPASSWORDS(ISOUID, DATECREATE, DATELASTCHANGE, CURRENTPASS, OLDPASS)
VALUES(curUserID, userDateCreated, SYSDATE, newUserPwd, oldUserPwd)
END;
END IF;
我收到此错误:
Error(30,7): PL/SQL: ORA-00933: SQL command not properly ended
Error(31,7): PLS-00103: Encountered the symbol "IF" when expecting one of the following: ; <an identifier> <a double-quoted delimited-identifier>
也许这只是我遗漏的一个小错误?
答案 0 :(得分:3)
正确的语法是:
for i in `find . -type f `;do filename=`ls $i | cut -f 2 -d "."`; mv $i ./$filename.ext; done
您的代码是有效的:
IF condition THEN
statements
END IF;
IF condition THEN
BEGIN
statements
END;
答案 1 :(得分:2)
您收到第一个错误,因为您需要在BEGIN块之前添加THEN子句,以使ID语句的语法完整和正确。
您收到第二个错误:
错误(30,7):PL / SQL:ORA-00933:SQL命令未正确结束
因为您尚未完成INSERT语句。用分号终止它,这应该可以解决这个错误。
IF NOT EXISTS
(
SELECT ISOUID
FROM OLDUSERPASSWORDS
WHERE ISOUID=curIsoUserUID
)
THEN
BEGIN
INSERT INTO OLDUSERPASSWORDS(ISOUID, DATECREATE, DATELASTCHANGE, CURRENTPASS, OLDPASS)
VALUES(curUserID, userDateCreated, SYSDATE, newUserPwd, oldUserPwd);
END;
END IF;
答案 2 :(得分:1)
您忘记THEN
之前的BEGIN
,IF NOT EXISTS
。