Advertisement
MagnusArias

DB2 | Procedury

Apr 23rd, 2018
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.13 KB | None | 0 0
  1. CREATE OR REPLACE PROCEDURE PROC1 (IN V1 DECIMAL(8, 2), IN V2 DECIMAL(8, 2), OUT W DECIMAL(10,2) )
  2. P1: BEGIN
  3.     -- #######################################################################
  4.     -- # Returns count of tables created by DB2ADMIN and like VARNAME
  5.     -- #######################################################################
  6.     SET W = V1 + V2;
  7. END P1
  8.  
  9.  
  10.  
  11. SELECT EMPNO, JOB, COMM
  12.   FROM EMPLOYEE
  13.   WHERE EMPNO NOT LIKE '%10';
  14.  
  15. CREATE TABLE datatab
  16. (
  17.     EMP_ID INTEGER,
  18.     SAL DECIMAL(8,2)
  19. );
  20.  
  21. CREATE TABLE SALARIES
  22. (
  23. EMP_ID INTEGER,
  24. SALARY DECIMAL(8,2),
  25. JOB VARCHAR(10)
  26. );
  27.  
  28. INSERT INTO SALARIES(EMP_ID, SALARY, JOB)
  29. SELECT EMPNO, COMM, JOB FROM EMPLOYEE;
  30.  
  31.  
  32. -- 2000 do 3000
  33. UPDATE SALARIES
  34. SET SALARY = SALARY * 1.10
  35. WHERE SALARY BETWEEN 2000 AND 3000 AND JOB NOT LIKE 'PRES';
  36.  
  37. -- ponizej 2000
  38. UPDATE SALARIES
  39. SET SALARY = SALARY * 1.15
  40. WHERE SALARY < 2000 AND JOB NOT LIKE 'PRES';
  41.  
  42. -- powyzej 3000
  43. UPDATE SALARIES
  44. SET SALARY = SALARY * 1.05
  45. WHERE SALARY > 3000 AND JOB NOT LIKE 'PRES';
  46.  
  47. SELECT e.EMPNO, e.JOB, e.COMM, d.SALARY FROM EMPLOYEE e, SALARIES d
  48. WHERE e.EMPNO = d.EMP_ID;
  49.  
  50. SELECT * FROM SALARIES;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement