欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

oracle if else 博客分类: Oracle小记 oracleifelseelseif 

程序员文章站 2024-02-13 16:31:40
...

oracle中的if else

 

 

 if instr(pagesql,'group by') >= 1 then
      v_sql := 'select * from ('||pagesql||') where rn between '||v_pb||' and '||v_pd;
     else if instr(pagesql,'where') >= 1 
      then  v_innner_sql := pagesql||' and rownum <= '||v_pd; v_sql:='select * from ('||v_innner_sql||') where rn >='||v_pb;
     else
       v_innner_sql := pagesql || ' where rownum <= '|| v_pd; v_sql:='select * from ('||v_innner_sql||') where rn >='||v_pb;
     end if;
     end if;

 网上搜可以用elseif,可是根本不成啊,不知道怎么回事

 最后用上边的方法搞定了

后来才知道是elsif,所以上边可以直接用

 

 if instr(pagesql,'group by') >= 1 then
       v_sql := 'select * from ('||pagesql||') where rn between '||v_pb||' and '||v_pd;
 elsif instr(pagesql,'where') >= 1 then
       v_innner_sql := pagesql||' and rownum <= '||v_pd; v_sql:='select * from ('||v_innner_sql||') where rn >='||v_pb;
 else
       v_innner_sql := pagesql || ' where rownum <= '|| v_pd; v_sql:='select * from ('||v_innner_sql||') where rn >='||v_pb;
 end if;