--下例中使用了for,loop和if,请参考一下: --题目:字符串'http://www.csdn.net/point.aspx'中,如何获得字符串“csdn.net”?--做了个取二级域名的函数如下:SQL> CREATE OR REPLACE FUNCTION f_twodomain(http0 IN varchar2) RETURN varchar2 IS 2 v_str_twodomain varchar2(80); 3 begin 4 For i in 12..100 5 Loop 6 if ascii(substr(http0,i,1))=47 then 7 return v_str_twodomain; 8 end if; 9 v_str_twodomain:=v_str_twodomain || substr(http0,i,1); 10 End loop; 11 end; 12 /Function createdSQL> select f_twodomain('http://www.csdn.net/point.aspx') from dual;F_TWODOMAIN('HTTP://WWW.CSDN.N -------------------------------------------------------------------------------- csdn.netSQL>
9i 10G 还没有break 这个关键字,我觉得这个很不爽
只知道function里可以直接用return
create or replace function uf_test(i_num number) return number is begin if i_num>10 then <<flag>> if i_num>100 then goto flag; end if; end if; return(10); end uf_test;
--下例中使用了for,loop和if,请参考一下:
--题目:字符串'http://www.csdn.net/point.aspx'中,如何获得字符串“csdn.net”?--做了个取二级域名的函数如下:SQL> CREATE OR REPLACE FUNCTION f_twodomain(http0 IN varchar2) RETURN varchar2 IS
2 v_str_twodomain varchar2(80);
3 begin
4 For i in 12..100
5 Loop
6 if ascii(substr(http0,i,1))=47 then
7 return v_str_twodomain;
8 end if;
9 v_str_twodomain:=v_str_twodomain || substr(http0,i,1);
10 End loop;
11 end;
12 /Function createdSQL> select f_twodomain('http://www.csdn.net/point.aspx') from dual;F_TWODOMAIN('HTTP://WWW.CSDN.N
--------------------------------------------------------------------------------
csdn.netSQL>
is
begin
if i_num>10 then
<<flag>>
if i_num>100 then
goto flag;
end if;
end if;
return(10);
end uf_test;