nantunes

Ficha 12_ex4_5

May 12th, 2021
431
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DO $$ DECLARE
  2.             v_name cust.c_last%TYPE;
  3.          BEGIN
  4.             FOR i IN 1..3
  5.             LOOP
  6.                FOR j IN 1..3000
  7.                LOOP
  8.                  EXECUTE
  9.                     'select c_last from cust
  10.                     where c_w_id=1
  11.                     and c_d_id='||i||' and c_id='||j
  12.                  INTO v_name;
  13.                -- Do something with v_name
  14.              END LOOP;
  15.           END LOOP;
  16. END; $$;
  17. DO
  18.  
  19. -- Time: 320.927 ms
  20.  
  21. -- 5. Tune the PL/SQL block above. Consider only the lines related to the SELECT command.
  22.  
  23. DO $$
  24. DECLARE
  25.   v_name cust.c_last%TYPE;
  26. BEGIN
  27.       FOR i IN 1..3
  28.       LOOP
  29.         FOR j IN 1..3000
  30.         LOOP
  31.             SELECT c_last INTO v_name FROM cust
  32.               WHERE c_w_id=1
  33.               AND c_d_id=i AND c_id=j;
  34.        END LOOP;
  35.     END LOOP;
  36. END;
  37. $$;
  38. DO
  39. -- Time: 35.848 ms
  40.  
RAW Paste Data