Oracle11g numerical loop overflow

I have a for loop in the pl / sql function something like:

FOR i IN min..max LOOP

variables i, min, max are declared as NUMERIC

in my case min and max are very large, but the range itself is small, i.e.

min = 3232236033
max = 3232236286

since you see a range of about ~ 256, but with these values, oracle gives a numerical overflow error and I focused on how to make it work.

How should I iterate over these values?

EDIT

Ok, I have a working answer using max / min diff loop, but is it really impossible to scroll large values ​​in oracle?

EDIT The error I get:

SQL Error: ORA-01426: nadmiar numeryczny
ORA-06512: przy "PS.DHCP", linia 88
01426. 00000 -  "numeric overflow"
*Cause:    Evaluation of an value expression causes an overflow/underflow.
*Action:   Reduce the operands.

Line 88 of the code:

FOR client_ip IN min_host..max_host

min_host, max_host, client_ip - result inet_aton(numeric representation of IP)

+3
source share
2 answers

, - , ( pl/sql), :

while

set serveroutput on
/
declare
 min_val number;
 max_val number ;
 iterator number ;
begin
    min_val := 3232236033 ;
    max_val := 3232236286 ;

    iterator := min_val;
    while iterator<=max_val loop
        dbms_output.put_line(iterator);
        iterator  := iterator  + 1;
    end loop ;

end;
/

: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/controlstatements.htm#BABEFFDC

FOR LOOP Index

FOR LOOP INTEGER, . , . . FOR LOOP index undefined. ( .)

4-17 FOR LOOP , .

: http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/loop_statement.htm

_

, ( ). - ; .

index_name . , . . 4-22, " , Loop ".

: , .

, "" , INDEX (, , )

+6

0 min max. , DBMS_OUTPUT:

DECLARE
  v_min     INTEGER := 3232236033;
  v_max     INTEGER := 3232236286;
  v_diff    PLS_INTEGER;
BEGIN
  v_diff := v_max - v_min;
  FOR i IN 0..v_diff
  LOOP
    -- Use v_min + i where you would have used i.
    dbms_output.put_line(v_min + i);
  END LOOP;
END;
/

: , . .. +/- 2 31. PL/SQL:

PL/SQL PLS_INTEGER , , . PLS_INTEGER -2 ** 31.. 2 ** 31. , , PL/SQL .

+2

Source: https://habr.com/ru/post/1793101/


All Articles