SHARE
TWEET

seminar sgbd 9

a guest Apr 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create or replace package  grupa_1044 is
  2. cota_tva constant number := 19;
  3. function get_val_cu_tva(p_val number) return number;
  4. end;
  5. /
  6.  
  7. set serveroutput on;
  8.  
  9. create or replace package body grupa_1044 is
  10.  
  11. function get_val_cu_tva(p_val number) return number
  12. is
  13. begin return p_val *( 1+ cota_tva/100);
  14. end get_val_cu_tva;
  15.  function get_valoare_comanda  ( p_id_client number,p_an number default 1998)
  16. return number is
  17. v_val number;
  18. begin
  19. select sum(pret*cantitate) into v_val  from rand_comenzi r join comenzi co on r.nr_comanda=co.nr_comanda    and
  20. co.id_client = p_id_client and extract (year from data )= p_an;
  21. return v_val;
  22. end ;
  23. function get_val_cu_tva2(p_val number , p_cota number ) return number
  24. is
  25. begin
  26. return p_val *(1+p_cota/100*get_valoare_comanda(103));
  27. end get_val_cu_tva2;
  28.  
  29. end grupa_1044;
  30. /
  31.  
  32. begin
  33. DBMS_OUTPUT.PUT_LINE ('cota standard tva : ' || grupa_1044.cota_tva);
  34. dbms_output.put_line ( 'val cu tva standard : ' || grupa_1044.get_val_cu_tva(200));
  35. dbms_output.put_line ( 'val cu tva 5% : ' || grupa_1044.get_val_cu_tva2(200 ,5));
  36.  
  37. end;
  38. /
  39. create or replace package body grupa_1044 is
  40.  
  41. function get_val_cu_tva(p_val number  ) return number
  42.  
  43.  
  44. is
  45. begin return p_val *( 1+ cota_tva/100);
  46. end get_val_cu_tva;
  47.  function get_valoare_comanda  ( p_id_client number,p_an number default 1998)
  48. return number is
  49. v_val number;
  50. begin
  51. select sum(pret*cantitate) into v_val  from rand_comenzi r join comenzi co on r.nr_comanda=co.nr_comanda    and
  52. co.id_client = p_id_client and extract (year from data )= p_an;
  53. return v_val;
  54. end ;
  55. end grupa_1044;
  56.  
  57.  
  58. /
  59. -- sa se construiasca un pachet ce contine o functie si o procedura si sa se apeleze functia si procedura
  60. create or replace package  grupa_1000 is
  61.  
  62. function suma(p_val number,p_val2 number) return number;
  63. procedure construim_tabela(f_nume_tabela varchar2);
  64. end;
  65. /
  66. create or replace package body grupa_1000 is
  67. function suma (p_val number, p_val2 number) return number
  68. is
  69. begin return (p_val+p_val2);
  70. end suma;
  71.  procedure construim_tabela( f_nume_tabela varchar2) is n number;
  72. begin
  73. select count(*) into n from user_tables where table_name = f_nume_tabela;
  74. if n=0 then
  75. execute immediate' create table' || f_nume_tabela || '(n number)';
  76. else
  77. execute immediate 'drop table' || f_nume_tabela;
  78. end if;
  79. end;
  80.  
  81. end;
  82. /
  83. begin
  84. dbms_output.put_line( ' suma ' || grupa_1000.suma(10,5));
  85. construim_tabela('abcde');
  86. end;
  87.  
  88. /
  89.  
  90. create or replace package diaconita is
  91. function suma( n1 number, n2 number) return number;
  92. procedure Paste_Fericit( p_nume varchar2, p_urare OUT varchar2);
  93. end;
  94. /
  95.  
  96.  
  97. create or replace package body diaconita is
  98. function suma( n1 number, n2 number) return number
  99. is begin return n1+n2;
  100. end suma;
  101. procedure Paste_Fericit( p_nume varchar2, p_urare OUT varchar2)
  102. is
  103. begin
  104. p_urare:= 'Paste fericit' || p_nume;
  105. end Paste_Fericit;
  106. end;
  107. /
  108.  
  109.  
  110. declare
  111. m varchar2(50);
  112. begin
  113.  
  114. dbms_output.put_line( diaconita.suma(10,5));
  115. diaconita.Paste_Fercit('Vlad',m);
  116. dbms_output.put_line(m);
  117. end;
  118. /
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top