How do you create a procedure stored in Oracle?

0

How could you obtain the numeric data of a specific table to perform an operation using a stored procedure that returns, for example, the division of these two data into another field in the same table?

    
asked by oscar gonperz 14.06.2018 в 09:47
source

1 answer

0

Oscar, the simplest thing would be this, you have a table of three fields (FIELD1, FIELD2, DIVISION) and an associated stored procedure would be like this:

PROCEDURE SP_UPD_MITABLA() IS
    BEGIN 
        UPDATE MITABLA
        SET CAMPO_DIVISION = (CAMPO1/CAMPO2)
        WHERE --ALGUNA LOGICA DE FILTRO
        COMMIT;
    END;

Obviously, you should be careful that CAMPO2 was never zero or zero for example, to avoid errors.

    
answered by 22.01.2019 в 19:02