Entradas

Mostrando entradas de abril 30, 2014

FUNCIONES EN ORACLE

FUNCIONES EN ORACLE
***********************
CREATE OR REPLACE FUNCTION f_sumar(n1 number, n2 number)
return number
IS
rpta number;
BEGIN
    rpta:=n1+n2;
    return (rpta);  
END;
select f_sumar(52,121) from dual;
--------------------------------------------------------------------
CREATE OR REPLACE FUNCTION f_cubos(num number)
  return number
IS
  v_cubo number;
BEGIN
     return (num*num*num);
END;

select f_cubos(2) from dual;
---------------------------------------------------------------------
CREATE OR REPLACE FUNCTION f_promedio(nt1 number, nt2 number, nt3 number, nt4 number)
return number
IS
BEGIN
    return ((nt1+nt2+nt3+nt4)/4);  
END;

select f_promedio(14,15,13,11) from dual;


---------------------------------------------------------------------
CREATE OR REPLACE FUNCTION f_maximo(num1 number, num2 number)
return number
IS
may number;
BEGIN
    IF (num1>num2) THEN
       may:= num1;
     ELSE
       may:= num2;
      END IF;
      RETURN may;
END;

select f_maximo(14,15)…