for example:
create table t1(a int);
insert into t1 values (1);
insert into t1 values (3);
insert into t1 values (5);
insert into t1 values (7);
insert into t1 values (9);
create or replace function get_val return varchar2 is
p_out number;
tp_no number;
tp_count number;
begin
p_out:=0;
loop
select mod(dbms_random.random(),10) into tp_no from dual;
select count(*) into tp_count from t1 where a=tp_no;
if tp_count>0 then
p_out:=1;
end if;
exit when p_out=1;
end loop;
return(tp_no);
end;
/
create table t1(a int);
insert into t1 values (1);
insert into t1 values (3);
insert into t1 values (5);
insert into t1 values (7);
insert into t1 values (9);
create or replace function get_val return varchar2 is
p_out number;
tp_no number;
tp_count number;
begin
p_out:=0;
loop
select mod(dbms_random.random(),10) into tp_no from dual;
select count(*) into tp_count from t1 where a=tp_no;
if tp_count>0 then
p_out:=1;
end if;
exit when p_out=1;
end loop;
return(tp_no);
end;
/
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货