使用COUNT(*)不就行了吗?
 select count(*) into temp from user   where id...
if temp=0 then
else
end if

解决方案 »

  1.   

    to:weiwei:
     user表(id number,name varchar2(20))
    输入id的起号和结束号,查询那些id已经在用,那些id 不在用。to :飘
       我是说用一个sql语句写出。
    等。。
      

  2.   

    select a.id,nvl(a.status,'不在用') status from 
    (
        select id,'在用' status from user where id>0 and id<5
    ) a,
    (
        select rownum id from all_tables where rownum<5
    ) b
    where b.id=a.id(+);
      

  3.   

    select a.id,nvl(a.status,'不在用') status from 
    (
        select id,'在用' status from user where id>X and id<Y
    ) a,
    (
        select rownum+X id from all_tables where rownum<Y
    ) b
    where b.id=a.id(+);当条件id>0 and id<5变化为id>X and id<Y
      

  4.   

    select a.id,nvl(a.status,'不在用') status from 
    (
        select id,'在用' status from user where id>X and id<Y
    ) a,
    (
        select rownum+X id from all_tables where rownum<Y-X
    ) b
    where b.id=a.id(+);改一下