- 注册时间
- 2009-7-21
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 4489
- 在线时间
- 小时
|
楼主 |
发表于 2010-6-14 14:08:26
|
显示全部楼层
过程式语言的写法,和SQL时间差不多-
- create or replace procedure pc5
- as
- time_before BINARY_INTEGER;
- time_after BINARY_INTEGER;
- TYPE t_num IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER ;
- x t_num;
- a t_num;
- b t_num;
- c PLS_INTEGER;
- c1 PLS_INTEGER;
- r PLS_INTEGER;
- l varchar(4);
- begin
- c:=0;
- time_before := DBMS_UTILITY.GET_TIME;
- for i in to_number('1234','fm0xxx')..to_number('cba9','fm0xxx') loop
- l:=to_char(i,'fm0xxx');
- if substr(l,1,1)<>substr(l,2,1)and
- substr(l,2,1)<>substr(l,3,1)and
- substr(l,3,1)<>substr(l,4,1)and
- substr(l,1,1)<>substr(l,3,1)and
- substr(l,2,1)<>substr(l,4,1)and
- substr(l,1,1)<>substr(l,4,1)and
- instr(l,0)=0 and instr(l,'d')=0 and instr(l,'e')=0 and instr(l,'f')=0 then
- c:=c+1;
- if i<to_number('cba9','fm0xxx')/2 then
- a(c):=i;
- c1:=c;
- end if;
- b(c):=i;
- x(i):=c;
- else
- x(i):=c;
- end if;
- end loop;
- r:=0;
- dbms_output.put_line('c='||c||'c1='||c1||a(1)||b(1));
- FOR I IN 1 .. c1 LOOP
- FOR J IN x(a(i))+1 .. x(to_number('cba9','fm0xxx')-a(i)) LOOP
- --if translate('123456789abc','\$'||to_char(a(i),'fm0xxx')||to_char(b(j),'fm0xxx')||to_char(a(i)+b(j),'fm0xxx'),'\$')is null then
- --dbms_output.put_line(to_char(a(i),'fm0xxx')||to_char(b(j),'fm0xxx')||to_char(a(i)+b(j),'fm0xxx'));
- --NULL;
- l:=to_char(a(i)+b(j),'fm0xxx');
- if substr(l,1,1)<>substr(l,2,1)and
- substr(l,2,1)<>substr(l,3,1)and
- substr(l,3,1)<>substr(l,4,1)and
- substr(l,1,1)<>substr(l,3,1)and
- substr(l,2,1)<>substr(l,4,1)and
- substr(l,1,1)<>substr(l,4,1)and
- instr(l,0)=0 and instr(l,'d')=0 and instr(l,'e')=0 and instr(l,'f')=0
- --length(translate('0def','\$'||l,'\$'))=4
- and length(translate(to_char(a(i),'fm0xxx'),'\$'||l,'\$'))=4
- and length(translate(to_char(b(j),'fm0xxx'),'\$'||l,'\$'))=4
- and length(translate(to_char(a(i),'fm0xxx'),'\$'||to_char(b(j),'fm0xxx'),'\$'))=4 then
- r:=r+1;
- --dbms_output.put_line(to_char(a(i),'fm0xxx')||to_char(b(j),'fm0xxx')||to_char(a(i)+b(j),'fm0xxx'));
- end if;
- end loop;
- if r>=100 then
- exit;
- end if;
- end loop;
-
- time_after := DBMS_UTILITY.GET_TIME;
- DBMS_OUTPUT.PUT_LINE ('output:'||(time_after - time_before)||'rows:'||r);
- end;
- /
-
复制代码 |
|