Databases Reference
In-Depth Information
4.
Create the function C_N_K_CACHE with the RESULT_CACHE option:
CREATE OR REPLACE FUNCTION C_N_K_CACHE (N IN NUMBER,
K IN NUMBER) RETURN NUMBER RESULT_CACHE
IS
N_FAT NUMBER := 1;
K_FAT NUMBER := 1;
N_K_FAT NUMBER := 1;
BEGIN
FOR J IN 1..N LOOP
N_FAT := N_FAT * J;
END LOOP;
FOR J IN 1..K LOOP
K_FAT := K_FAT * J;
END LOOP;
FOR J IN 1..(N - K) LOOP
N_K_FAT := N_K_FAT * J;
END LOOP;
RETURN (N_FAT / (N_K_FAT * K_FAT));
END;
/
5.
Create the STRESS_CACHE procedure to test the C_N_K_CACHE function:
CREATE OR REPLACE PROCEDURE STRESS_CACHE(ANUM NUMBER)
IS
AVAL NUMBER;
BEGIN
FOR J IN 1..ANUM LOOP
AVAL := C_N_K_CACHE (50,10);
END LOOP;
END;
/
 
Search WWH ::




Custom Search