Create or replace procedure PROC_PRINT_TABLE_INPUT ( PV_NUMBER IN Number)
is
i number;
begin
for i in 1..10
loop
dbms_output.put_line(PV_NUMBER||' x '||i||' = '||PV_NUMBER*i);
end loop;
exception
WHEN no_data_found then
dbms_output.put_line('INPUT NO IS INVALID'||' '||PV_NUMBER);
End PROC_PRINT_TABLE_INPUT;
Output :
Begin
PROC_PRINT_TABLE_INPUT (2);
end;
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20
************************************************
create or replace function FUNC_PRINT_TABLE_INPUT ( PV_NUMBER IN Number)
return number
is
/* n number;*/
i number;
X number;
begin
/*n:=PV_NUMBER;*/
for i in 1..10
loop
dbms_output.put_line(PV_NUMBER||' x '||i||' = '||PV_NUMBER*i);
end loop;
return X;
exception
WHEN no_data_found then
return 0;
end;
output ;
execute:
declare
X varchar(500);
begin
X:=FUNC_PRINT_TABLE_INPUT (4);
dbms_output.put_line(X);
END;
result :
4 x 1 = 4
4 x 2 = 8
4 x 3 = 12
4 x 4 = 16
4 x 5 = 20
4 x 6 = 24
4 x 7 = 28
4 x 8 = 32
4 x 9 = 36
4 x 10 = 40
is
i number;
begin
for i in 1..10
loop
dbms_output.put_line(PV_NUMBER||' x '||i||' = '||PV_NUMBER*i);
end loop;
exception
WHEN no_data_found then
dbms_output.put_line('INPUT NO IS INVALID'||' '||PV_NUMBER);
End PROC_PRINT_TABLE_INPUT;
Output :
Begin
PROC_PRINT_TABLE_INPUT (2);
end;
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20
************************************************
create or replace function FUNC_PRINT_TABLE_INPUT ( PV_NUMBER IN Number)
return number
is
/* n number;*/
i number;
X number;
begin
/*n:=PV_NUMBER;*/
for i in 1..10
loop
dbms_output.put_line(PV_NUMBER||' x '||i||' = '||PV_NUMBER*i);
end loop;
return X;
exception
WHEN no_data_found then
return 0;
end;
output ;
execute:
declare
X varchar(500);
begin
X:=FUNC_PRINT_TABLE_INPUT (4);
dbms_output.put_line(X);
END;
result :
4 x 1 = 4
4 x 2 = 8
4 x 3 = 12
4 x 4 = 16
4 x 5 = 20
4 x 6 = 24
4 x 7 = 28
4 x 8 = 32
4 x 9 = 36
4 x 10 = 40
0 Comments