Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

set serveroutput on

declare

num1 number :=0;

num2 number:=0;

total number :=0;

begin

num1:=&num1;

num2:=&num2;

total :=num1+num2;

dbms_output.put_line(‘la suma es:’ ||total);

end;

set serveroutput on

declare

num1 number :=0;

num2 number:=0;
num3 number:=0;

mayor number :=0;

begin

num1:=&num1;

num2:=&num2;

num3:=&num3;

if (num1>num2 and num1>num3) then

mayor :=num1;

elsif (num2>num1 and num2>num3) then

mayor :=num2;

else

mayor :=num3;

end if;

dbms_output.put_line(‘el mayor es :’ || mayor);

end;

/
declare

num1 number :=0;

num2 number:=0;

total number:=0;

operacion varchar2(1) :=’’;

begin

num1:=&num1;

num2:=&num2;

operacion:=’&operacion’;

CASE operacion
when ‘+’ then total := num1+num2;

when ‘-‘ then total:=num1-num2;

when ‘*‘ then total:=num1*num2;

when ‘/’ then

if (num2>0) then

total := num1/num2;

else

dbms_output.put_line(‘Division por 0 :’);

end if;

else

dbms_output.put_line(‘Operación invalida :’);

end case;

dbms_output.put_line(‘el total es :’ || total);

end;

/
declare

num1 number :=0;

num2 number:=0;

total number:=0;

fechayhora varchar2(30):=’’;

operacion varchar2(1) :=’’;

begin
num1:=&num1;

num2:=&num2;

operacion:=’&operacion’;

select to_char (sysdate, ‘dd/mon/yyyy hh;mi:ss’)

into fechayhora

from dual;

CASE operacion

when ‘+’ then total := num1+num2;

when ‘-‘ then total:=num1-num2;

when ‘*‘ then total:=num1*num2;

when ‘/’ then

if (num2>0) then

total := num1/num2;

else

dbms_output.put_line(‘Division por 0 :’);

end if;

else

dbms_output.put_line(‘Operación invalida :’);

end case;

dbms_output.put_line(‘el total es :’ || total);

dbms_output.put_line(‘Hoy, ‘|| fechayhora||’ el resultado fue ’||total);

end;

/
declare

num1 number :=0;

num2 number:=0;

total number:=0;

fechayhora varchar2(30):=’’;

operacion varchar2(1) :=’’;

begin

num1:=&num1;
num2:=&num2;

operacion:=’&operacion’;

select to_char (sysdate, ‘dd/mon/yyyy hh;mi:ss’)

into fechayhora

from dual;

CASE operacion

when ‘+’ then total := num1+num2;

when ‘-‘ then total:=num1-num2;

when ‘*‘ then total:=num1*num2;

when ‘/’ then

if (num2>0) then

total := num1/num2;

else

dbms_output.put_line(‘Division por 0 :’);

end if;

else

dbms_output.put_line(‘Operación invalida :’);

end case;

dbms_output.put_line(‘el total es :’ || total);

dbms_output.put_line(‘Hoy, ‘|| fechayhora||’ el resultado fue ’||total);

insert into registro values(‘Hoy, ‘|| fechayhora||’ el resultado fue ’||total);

end;

/
declare

num1 number :=0;

nums number :=0;

begin

num1:=&num1;

for i in 1..num1

loop

nums:=num1+i;
end loop;

dbms_output.put_line(‘numero :’ || nums);

end;

You might also like