-
Notifications
You must be signed in to change notification settings - Fork 0
/
16. GOTO Statement (Code Samples).html
43 lines (43 loc) · 1.34 KB
/
16. GOTO Statement (Code Samples).html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<pre class="prettyprint linenums">------------------------------GOTO STATEMENT----------------------------------
DECLARE
v_searched_number NUMBER := 22;
v_is_prime boolean := true;
BEGIN
FOR x in 2..v_searched_number-1 LOOP
IF v_searched_number MOD x = 0 THEN
dbms_output.put_line(v_searched_number|| ' is not a prime number..');
v_is_prime := false;
GOTO end_point;
END IF;
END LOOP;
if v_is_prime then
dbms_output.put_line(v_searched_number|| ' is a prime number..');
end if;
<<end_point>>
dbms_output.put_line('Check complete..');
END;
-------------------------------------------------------------------------------
DECLARE
v_searched_number NUMBER := 32457;
v_is_prime boolean := true;
x number := 2;
BEGIN
<<start_point>>
IF v_searched_number MOD x = 0 THEN
dbms_output.put_line(v_searched_number|| ' is not a prime number..');
v_is_prime := false;
GOTO end_point;
END IF;
x := x+1;
if x = v_searched_number then
goto prime_point;
end if;
goto start_point;
<<prime_point>>
if v_is_prime then
dbms_output.put_line(v_searched_number|| ' is a prime number..');
end if;
<<end_point>>
dbms_output.put_line('Check complete..');
END;
---------------------------------------------------------------------------------</pre>