Domanda

I am using Oracle, PL/SQL. I have written the following procedure:

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;

All I want it to do is :

Check username and password, if exists check count<=5, if true update count=0 where username='admin'. if username and pass exists and if count>5, update Isactive=0. And finally if username and password not exists, update count=count+1 where username=username.

the above Procedure is giving me this error

ORA-00911: invalid character Please Help.

È stato utile?

Soluzione

try this

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;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top