Tuesday, August 31, 2010

ORA-30009: Not enough memory for CONNECT BY operation and lotto

SQL> @lotto
SQL> select winnend_getal
2 from (
3 select winnend_getal, count(*)
4 from (
5 select round(DBMS_RANDOM.VALUE(1,45)) winnend_getal
6 from
7 ( select level n from dual
8 connect by level <= &aantal_nummers )
9 )
10 group by winnend_getal order by count(*) desc
11 )
12 where rownum <=6
13 /
Enter value for aantal_nummers: 1000000
old 8: connect by level <= &aantal_nummers )
new 8: connect by level <= 1000000 )
select round(DBMS_RANDOM.VALUE(1,45)) winnend_getal
*
ERROR at line 5:
ORA-30009: Not enough memory for CONNECT BY operation


Elapsed: 00:00:06.32
SQL> select winnend_getal
2 from (
3 select winnend_getal, count(*)
4 from (
5 select round(DBMS_RANDOM.VALUE(1,45)) winnend_getal
6 from
7 (
8 with n(n) as ( select 0
9 from dual
10 union all
11 select n+1 from n
12 where n<=&aantal_nummers
13 )
14 select * from n
15 )
16 )
17 group by winnend_getal order by count(*) desc
18 )
19 where rownum <= 6
20 /
Enter value for aantal_nummers: 1000000
old 12: where n<=&aantal_nummers
new 12: where n<=1000000

WINNEND_GETAL
-------------
35
15
12
9
41
11

6 rows selected.

Elapsed: 00:00:46.28
SQL>

I found this on asktom from a reply of user Sokrates ....

BTW Hope someone will win the lotto ....

No comments: