create or replace procedure num_group is
begin
insert into caipiao(haoma) values round((select dbms_random.value(1,35) from dual),0);
loop
if (select count(*) from (select distinct haoma from caipiao)) <7
then
insert into caipiao(haoma) values round((select dbms_random.value(1,35) from dual),0);
end if;
exit when (select count(*) from (select distinct haoma from caipiao))=6;
end loop;
end num_group;
先把查询结果赋值给变量 select count(*) into tmp from (select distinct haoma from caipiao) ,通过tmp比较