我正在使用Oracle,PL / SQL。 我写了以下程序:
Declare result number;
countExceed Number;
begin
select count(*) into result from
(select "LoginName","LoginPassword" from "ApplicationUser" where "LoginName"='adin' and "LoginPassword"='admin');
if result>0
then
execute immediate('Update "test" set "Count"=0 where "Count"<5');
dbms_output.put_line('Update as count 0!');
elsif result=0 then
execute immediate(' select "Count"
into countExceed from "test";
if countExceed >5 then
Update "test" set "Count"="Count"+1 where "Count" <5;
END IF;');
dbms_output.put_line('Update as Count + 1!');
End If;
end;
我想要做的就是:
检查用户名和密码,如果存在则检查计数&lt; = 5,如果真实更新计数= 0,则其中username =&#39; admin&#39;。 如果存在用户名和密码,并且如果count> 5,则更新Isactive = 0。最后 如果用户名和密码不存在,则更新count = count + 1,其中username = username。
上述程序给我这个错误
ORA-00911:无效字符 请帮助。
答案 0 :(得分:1)
试试这个
Declare result number;
countExceed Number;
begin
select count(*) into result from ApplicationUser where LoginName='adin' and LoginPassword='admin';
if result>0 then
execute immediate('Update "test" set "Count"=0 where "Count"<5');
dbms_output.put_line('Update as count 0!');
else
select "Count" into countExceed from "test";
if countExceed >5 then
execute immediate('Update "test" set "Count"="Count"+1 where "Count" <5');
END IF;
dbms_output.put_line('Update as Count + 1!');
End If;
end;