If I execute the following in a file with the pgsql command, it complains that the procedure needs to be called with 'perform'. But when I try to use perform, it tells me that perform is not defined. What's the solution?

   create or replace function waitris() returns void as $$
    declare
    count integer;
    begin
    LOOP
     select count(*) into count from taskflag where taskid = 'rdfdb' and state != 2;
     if count = 0 then   
        exit;
     end if;
     select pg_sleep(1);
    end loop;
    end;
    $$ language plpgsql;
    
    select waitris();