Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. -- PL/SQL Block Procedure
  2. DECLARE
  3. a number;
  4. b number;
  5. c number;
  6. PROCEDURE findMin(x IN number, y IN number, z OUT number) IS
  7. BEGIN
  8. IF x < y THEN
  9. z:= x;
  10. ELSE
  11. z:= y;
  12. END IF;
  13. END;
  14. BEGIN
  15. a:= 23;
  16. b:= 45;
  17. findMin(a, b, c);
  18. dbms_output.put_line(' Minimum of (23, 45) : ' || c);
  19. END;
  20. /
  21.  
  22. -- Standalone / Schema Level Procedure
  23. CREATE OR REPLACE PROCEDURE findMin(x IN number, y IN number, z OUT number) IS
  24. BEGIN
  25. IF x < y THEN
  26. z:= x;
  27. ELSE
  28. z:= y;
  29. END IF;
  30. END;
  31.  
  32. DECLARE
  33. a number;
  34. b number;
  35. c number;
  36. BEGIN
  37. a:= 23;
  38. b:= 45;
  39. findMin(a, b, c);
  40. dbms_output.put_line(' Minimum of (23, 45) : ' || c);
  41. END;
  42. /
  43.  
  44. -- Standalone / Schema Level Function
  45. CREATE OR REPLACE FUNCTION total_produk
  46. RETURN number IS
  47. total number(2) := 0;
  48. BEGIN
  49. SELECT count(*) into total
  50. FROM produk;
  51. RETURN total;
  52. END;
  53. /
  54.  
  55. DECLARE
  56. c number(2);
  57. BEGIN
  58. c := total_produk();
  59. dbms_output.put_line('Total no. of Customers: ' || c);
  60. END;
  61. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement