一条SQL语句没有办法实现,可以通过存储过程,用游标实现。
解决方案 »
- 大家帮我看下,这个语句怎么错了啊?
- 问一下关于安装时的10150问题度娘了但是找不到结果
- 送分了~~
- 一个sql语句
- 请问ORACLE中,system,sys,root,sysdba,这4种用户的默认密码是什么,如果忘记了如何找到他们,我现在就忘记了,可我都不知道怎么找到。谢
- 关于表中每个字段值用另一张表来界定值的设计问题?
- 你从SQL里看到了什么? - 收集给Oracle PL/SQL 程序员的箴言
- ADO.net 中的Oracle 连接,在线等....
- 谁知道这个select语句什么意思??
- 已经有两个表,怎样在表间建立外键?
- ora-01578错 经查询是LOBSEGMENT数据块损坏,请问如何解决?急急
- 请教一个sql,怎样写一个结果集不再另一个结果集中的sql
return varchar2
is
str varchar2(20);
i integer;
iid integer;
frand numeric(16,2);
cursor cursor1 is
select id,dbms_random.value() rand from t_test where type = 1 order by rand;
cursor cursor2 is
select id,dbms_random.value() rand from t_test where type = 2 order by rand;
begin
str := '';
i := 0;
open cursor1;
loop
fetch cursor1 into iid,frand;
exit when cursor1%notfound;
i := i + 1;
if i <= 2 then
str := str||iid||':';
end if;
end loop;
close cursor1;
open cursor2;
i := 0;
loop
fetch cursor2 into iid,frand;
exit when cursor2%notfound;
i := i + 1;
if i <= 2 then
str := str||iid||':';
end if;
if i = 3 then
str := str||iid;
end if;
end loop;
close cursor2;
return str;
end ;
Result varchar2(100) Default '';
begin
for x in (
select id
from (
select id from (select id,dbms_random.value() rand from t_test where type = 1 order by rand) where rownum<=2
union
select id from (select id,dbms_random.value() rand from t_test where type = 2 order by rand) where rownum<=3
) )
loop
Result := Result||':'||x.id;
end loop;
if length(Result)>1 then
Result := substr(Result,2);
end if;
return(Result);
end getIDs;select getIDs AS myIDs from dual;