alexarcan

test2bdbb

Dec 19th, 2016
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.32 KB | None | 0 0
  1. --------------------------------------------------------
  2. -- File created - Monday-December-19-2016
  3. --------------------------------------------------------
  4. --------------------------------------------------------
  5. -- DDL for Sequence S_ANNOTATION
  6. --------------------------------------------------------
  7.  
  8. CREATE SEQUENCE "S_ANNOTATION" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 56 CACHE 10 NOORDER NOCYCLE ;
  9. /
  10. --------------------------------------------------------
  11. -- DDL for Table ANNOTATION
  12. --------------------------------------------------------
  13.  
  14. CREATE TABLE "ANNOTATION"
  15. ( "ID" NUMBER,
  16. "B_ID" NUMBER,
  17. "U_ID" NUMBER,
  18. "INFO" VARCHAR2(20 BYTE)
  19. ) ;
  20. /
  21. --------------------------------------------------------
  22. -- DDL for Table BUG
  23. --------------------------------------------------------
  24.  
  25. CREATE TABLE "BUG"
  26. ( "ID" NUMBER,
  27. "NAME" VARCHAR2(20 BYTE),
  28. "STATUS" VARCHAR2(20 BYTE) DEFAULT 'ACTIVE',
  29. "U_ID" NUMBER
  30. ) ;
  31. /
  32. --------------------------------------------------------
  33. -- DDL for Table USERS
  34. --------------------------------------------------------
  35.  
  36. CREATE TABLE "USERS"
  37. ( "ID" NUMBER,
  38. "NAME" VARCHAR2(20 BYTE),
  39. "TYPE" NUMBER
  40. ) ;
  41. /
  42. REM INSERTING into ANNOTATION
  43. SET DEFINE OFF;
  44. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (49,1,3,'ANNOTATIONTEXT2');
  45. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (50,1,2,'ADMIN_WAS_HERE');
  46. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (46,1,3,'Created issue.');
  47. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (47,1,3,'Nobody heped.');
  48. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (48,1,3,'ANNOTATIONTEXT');
  49. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (1,2,3,'hello');
  50. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (2,2,2,'admin1');
  51. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (3,3,3,'another one');
  52. Insert into ANNOTATION (ID,B_ID,U_ID,INFO) values (4,3,1,'admin other');
  53. REM INSERTING into BUG
  54. SET DEFINE OFF;
  55. Insert into BUG (ID,NAME,STATUS,U_ID) values (3,'OTHER_CLOSED','CLOSED',3);
  56. Insert into BUG (ID,NAME,STATUS,U_ID) values (1,'OPEN_BUG','ACTIVE',3);
  57. Insert into BUG (ID,NAME,STATUS,U_ID) values (2,'CLOSED_B','CLOSED',3);
  58. REM INSERTING into USERS
  59. SET DEFINE OFF;
  60. Insert into USERS (ID,NAME,TYPE) values (1,'GOD',0);
  61. Insert into USERS (ID,NAME,TYPE) values (2,'admin',0);
  62. Insert into USERS (ID,NAME,TYPE) values (3,'user',1);
  63. Insert into USERS (ID,NAME,TYPE) values (4,'normal',1);
  64. --------------------------------------------------------
  65. -- DDL for Index USERS_PK
  66. --------------------------------------------------------
  67.  
  68. CREATE UNIQUE INDEX "USERS_PK" ON "USERS" ("ID")
  69. ;
  70. /
  71. --------------------------------------------------------
  72. -- DDL for Index ANNOTATION_PK
  73. --------------------------------------------------------
  74.  
  75. CREATE UNIQUE INDEX "ANNOTATION_PK" ON "ANNOTATION" ("ID")
  76. ;
  77. /
  78. --------------------------------------------------------
  79. -- DDL for Index BUG_PK
  80. --------------------------------------------------------
  81.  
  82. CREATE UNIQUE INDEX "BUG_PK" ON "BUG" ("ID")
  83. ;
  84. /
  85. --------------------------------------------------------
  86. -- Constraints for Table USERS
  87. --------------------------------------------------------
  88.  
  89. ALTER TABLE "USERS" MODIFY ("ID" NOT NULL ENABLE);
  90.  
  91. ALTER TABLE "USERS" MODIFY ("NAME" NOT NULL ENABLE);
  92.  
  93. ALTER TABLE "USERS" MODIFY ("TYPE" NOT NULL ENABLE);
  94.  
  95. ALTER TABLE "USERS" ADD CONSTRAINT "USERS_PK" PRIMARY KEY ("ID") ENABLE;
  96. /
  97. --------------------------------------------------------
  98. -- Constraints for Table BUG
  99. --------------------------------------------------------
  100.  
  101. ALTER TABLE "BUG" ADD CONSTRAINT "BUG_PK" PRIMARY KEY ("ID") ENABLE;
  102.  
  103. ALTER TABLE "BUG" MODIFY ("NAME" NOT NULL ENABLE);
  104.  
  105. ALTER TABLE "BUG" MODIFY ("ID" NOT NULL ENABLE);
  106.  
  107. ALTER TABLE "BUG" MODIFY ("STATUS" NOT NULL ENABLE);
  108.  
  109. ALTER TABLE "BUG" MODIFY ("U_ID" NOT NULL ENABLE);
  110. /
  111. --------------------------------------------------------
  112. -- Constraints for Table ANNOTATION
  113. --------------------------------------------------------
  114.  
  115. ALTER TABLE "ANNOTATION" ADD CONSTRAINT "ANNOTATION_PK" PRIMARY KEY ("ID") ENABLE;
  116.  
  117. ALTER TABLE "ANNOTATION" MODIFY ("ID" NOT NULL ENABLE);
  118.  
  119. ALTER TABLE "ANNOTATION" MODIFY ("INFO" NOT NULL ENABLE);
  120.  
  121. ALTER TABLE "ANNOTATION" MODIFY ("B_ID" NOT NULL ENABLE);
  122.  
  123. ALTER TABLE "ANNOTATION" MODIFY ("U_ID" NOT NULL ENABLE);
  124. /
  125. --------------------------------------------------------
  126. -- Ref Constraints for Table ANNOTATION
  127. --------------------------------------------------------
  128.  
  129. ALTER TABLE "ANNOTATION" ADD CONSTRAINT "ANNOTATION_BUG_FK1" FOREIGN KEY ("B_ID")
  130. REFERENCES "BUG" ("ID") ON DELETE CASCADE ENABLE;
  131.  
  132. ALTER TABLE "ANNOTATION" ADD CONSTRAINT "ANNOTATION_USERS_FK1" FOREIGN KEY ("U_ID")
  133. REFERENCES "USERS" ("ID") ON DELETE CASCADE ENABLE;
  134. /
  135. --------------------------------------------------------
  136. -- Ref Constraints for Table BUG
  137. --------------------------------------------------------
  138.  
  139. ALTER TABLE "BUG" ADD CONSTRAINT "BUG_USERS_FK1" FOREIGN KEY ("U_ID")
  140. REFERENCES "USERS" ("ID") ON DELETE CASCADE ENABLE;
  141. /
  142. --------------------------------------------------------
  143. -- DDL for Trigger T_ANNOTATION_ID
  144. --------------------------------------------------------
  145.  
  146. CREATE OR REPLACE TRIGGER "T_ANNOTATION_ID"
  147. BEFORE INSERT
  148. ON ANNOTATION
  149. REFERENCING NEW AS NEW
  150. FOR EACH ROW
  151. BEGIN
  152. IF(:NEW.ID IS NULL) THEN
  153. SELECT S_ANNOTATION.nextval
  154. INTO :new.ID
  155. FROM dual;
  156. end if;
  157. END;
  158. /
  159. ALTER TRIGGER "T_ANNOTATION_ID" ENABLE;
  160. /
  161. --------------------------------------------------------
  162. -- DDL for Function CREATE_ANNOTATION
  163. --------------------------------------------------------
  164.  
  165. CREATE OR REPLACE FUNCTION "CREATE_ANNOTATION" (userId IN ANNOTATION.U_ID%TYPE, bugId IN ANNOTATION.B_ID%TYPE, info IN ANNOTATION.INFO%TYPE)
  166. RETURN ANNOTATION.ID%TYPE IS
  167. created_id ANNOTATION.ID%TYPE := -1;
  168. CURSOR CREATED (userId IN ANNOTATION.U_ID%TYPE, bugId IN ANNOTATION.B_ID%TYPE, info IN ANNOTATION.INFO%TYPE) IS
  169. SELECT ID
  170. FROM ANNOTATION
  171. WHERE B_ID=bugId AND U_ID=userId AND INFO=info;
  172.  
  173. CURSOR VALID_CHECK_SUPERUSER (userId IN ANNOTATION.U_ID%TYPE) IS
  174. SELECT TYPE
  175. FROM USERS
  176. WHERE ID=userId;
  177.  
  178. userRole USERS.ID%TYPE := -1;
  179.  
  180. CURSOR BUG_OWNER (bugId IN ANNOTATION.B_ID%TYPE) IS
  181. SELECT U_ID
  182. FROM bug
  183. WHERE ID=bugId;
  184.  
  185. bugOwner BUG.U_ID%TYPE := -1;
  186.  
  187. CURSOR ACTIVE_COUNT (userId IN ANNOTATION.U_ID%TYPE) IS
  188. SELECT ID
  189. FROM BUG
  190. WHERE STATUS='ACTIVE' AND U_ID=userId;
  191.  
  192. activeCount BUG.ID%TYPE := 0;
  193.  
  194. CURSOR BUG_STATUS (bugId IN ANNOTATION.B_ID%TYPE) IS
  195. SELECT STATUS
  196. FROM BUG
  197. WHERE ID=bugId;
  198.  
  199. bugStatus BUG.STATUS%TYPE := '';
  200.  
  201. fk_violation_exception EXCEPTION;
  202. PRAGMA exception_init (fk_violation_exception, -2291);
  203. BEGIN
  204. OPEN VALID_CHECK_SUPERUSER(userId);
  205. FETCH VALID_CHECK_SUPERUSER INTO userRole;
  206. CLOSE VALID_CHECK_SUPERUSER;
  207.  
  208. IF (userRole != 0) THEN
  209. OPEN BUG_OWNER(bugId);
  210. FETCH BUG_OWNER INTO bugOwner;
  211. CLOSE BUG_OWNER;
  212. IF (bugOwner != userId) THEN
  213. RAISE_APPLICATION_ERROR(-20001, 'USER ' || userId || ' is not authorized to modify this issue!');
  214. END IF;
  215. END IF;
  216.  
  217. OPEN ACTIVE_COUNT(userId);
  218. FETCH ACTIVE_COUNT INTO activeCount;
  219. CLOSE ACTIVE_COUNT;
  220.  
  221. IF (activeCount != 1 AND userRole != 0)
  222. THEN RAISE_APPLICATION_ERROR(-20001, 'USER ' || userId || ' has no/more than one active issue(s)!');
  223. END IF;
  224.  
  225. OPEN BUG_STATUS(bugId);
  226. FETCH BUG_STATUS INTO bugStatus;
  227. CLOSE BUG_STATUS;
  228.  
  229. IF (bugStatus != 'ACTIVE')
  230. THEN RAISE_APPLICATION_ERROR(-20001, 'ISSUE ' || bugId || ' is not ACTIVE!');
  231. END IF;
  232.  
  233. INSERT INTO ANNOTATION (B_ID, U_ID, INFO)
  234. VALUES (bugId, userId, info);
  235.  
  236. OPEN CREATED(userId, bugId, info);
  237. FETCH CREATED INTO created_id;
  238. CLOSE CREATED;
  239. RETURN created_id;
  240. EXCEPTION
  241. WHEN fk_violation_exception THEN
  242. IF SQLERRM LIKE '%(STATIA01.ANNOTATION_BUG_FK1)%'
  243. THEN RAISE_APPLICATION_ERROR(-20001, 'ISSUE with id ' || bugId || ' does not exist!');
  244. ELSIF SQLERRM LIKE '%(STATIA01.ANNOTATION_USERS_FK1)%'
  245. THEN RAISE_APPLICATION_ERROR(-20001, 'USER with id ' || userId || ' does not exist!');
  246. ELSE RAISE;
  247. END IF;
  248. END;
  249.  
  250. /
  251.  
  252. /
  253. --------------------------------------------------------
  254. -- DDL for Function MKDIR
  255. --------------------------------------------------------
  256.  
  257. CREATE OR REPLACE FUNCTION "MKDIR" (userId IN ANNOTATION.U_ID%TYPE, bugId IN ANNOTATION.B_ID%TYPE, info IN ANNOTATION.INFO%TYPE)
  258. --dirId IN DIRS.ID%TYPE, dirName IN DIRS.NAME%TYPE)
  259. RETURN ANNOTATION.ID%TYPE IS
  260. created_id ANNOTATION.ID%TYPE := -1;
  261. CURSOR CREATED (userId IN ANNOTATION.U_ID%TYPE, bugId IN ANNOTATION.B_ID%TYPE, info IN ANNOTATION.INFO%TYPE) IS
  262. SELECT ID
  263. FROM ANNOTATION
  264. WHERE B_ID=bugId AND U_ID=userId AND INFO=info;
  265.  
  266. CURSOR ACTIVE_COUNT (userId IN ANNOTATION.U_ID%TYPE) IS
  267. SELECT ID
  268. FROM BUG
  269. WHERE STATUS='ACTIVE' AND U_ID=userId;
  270.  
  271. activeCount BUG.ID%TYPE := 0;
  272.  
  273. CURSOR BUG_STATUS (bugId IN ANNOTATION.B_ID%TYPE) IS
  274. SELECT STATUS
  275. FROM BUG
  276. WHERE ID=bugId;
  277.  
  278. bugStatus BUG.STATUS%TYPE := '';
  279.  
  280. fk_violation_exception EXCEPTION;
  281. PRAGMA exception_init (fk_violation_exception, -2291);
  282. BEGIN
  283. OPEN ACTIVE_COUNT(userId);
  284. FETCH ACTIVE_COUNT INTO activeCount;
  285. CLOSE ACTIVE_COUNT;
  286.  
  287. IF (activeCount != 1)
  288. THEN RAISE_APPLICATION_ERROR(-20001, 'USER ' || userId || ' has no/more than one active issue(s)!');
  289. END IF;
  290.  
  291. OPEN BUG_STATUS(userId);
  292. FETCH BUG_STATUS INTO bugStatus;
  293. CLOSE BUG_STATUS;
  294.  
  295. IF (bugStatus != 'ACTIVE')
  296. THEN RAISE_APPLICATION_ERROR(-20001, 'ISSUE ' || bugId || ' is not ACTIVE!');
  297. END IF;
  298.  
  299. INSERT INTO ANNOTATION (B_ID, U_ID, INFO)
  300. VALUES (bugId, userId, info);
  301.  
  302. OPEN CREATED(userId, bugId, info);
  303. FETCH CREATED INTO created_id;
  304. CLOSE CREATED;
  305. RETURN created_id;
  306. EXCEPTION
  307. WHEN fk_violation_exception THEN
  308. IF SQLERRM LIKE '%(STATIA01.ANNOTATION_BUG_FK1)%'
  309. THEN RAISE_APPLICATION_ERROR(-20001, 'ISSUE with id ' || bugId || ' does not exist!');
  310. ELSE IF SQLERRM LIKE '%(STATIA01.ANNOTATION_USERS_FK1)%'
  311. THEN RAISE_APPLICATION_ERROR(-20001, 'USER with id ' || userId || ' does not exist!');
  312. ELSE RAISE;
  313. END IF;
  314. END;
  315.  
  316. /
  317.  
  318. /
  319. --------------------------------------------------------
  320. -- DDL for Procedure FIND_CLOSED_ISSUES
  321. --------------------------------------------------------
  322. set define off;
  323.  
  324. CREATE OR REPLACE PROCEDURE "FIND_CLOSED_ISSUES" (userId IN BUG.U_ID%TYPE)
  325. IS
  326. CURSOR CLOSED (userId IN BUG.U_ID%TYPE) IS
  327. SELECT B.ID, B.NAME, B.U_ID
  328. FROM BUG B
  329. WHERE B.U_ID=userId AND B.STATUS='CLOSED';
  330.  
  331. CURSOR ANNOTATIONS_BY_BUG (bugId IN BUG.ID%TYPE) IS
  332. SELECT A.ID, A.U_ID, A.INFO
  333. FROM ANNOTATION A
  334. WHERE A.B_ID=bugId;
  335.  
  336. bugId BUG.ID%TYPE;
  337. bugName BUG.NAME%TYPE;
  338. bugOwner BUG.U_ID%TYPE;
  339. annotationId ANNOTATION.ID%TYPE;
  340. annotationUser ANNOTATION.U_ID%TYPE;
  341. annotationInfo ANNOTATION.INFO%TYPE;
  342. BEGIN
  343. OPEN CLOSED(userId);
  344. LOOP
  345. FETCH CLOSED INTO bugId, bugName, bugOwner;
  346. EXIT WHEN CLOSED%NOTFOUND;
  347. dbms_output.put_line('BUG: ' || bugId || ', called: ' || bugName || ' was created by user: ' || bugOwner);
  348. OPEN ANNOTATIONS_BY_BUG(bugId);
  349. LOOP
  350. FETCH ANNOTATIONS_BY_BUG INTO annotationId, annotationUser, annotationInfo;
  351. EXIT WHEN ANNOTATIONS_BY_BUG%NOTFOUND;
  352. dbms_output.put_line(' ANNOTATION: ' || annotationId || ', with info: ' || annotationInfo || ' was created by user: ' || annotationUser);
  353. END LOOP;
  354. CLOSE CLOSED;
  355. END LOOP;
  356. CLOSE CLOSED;
  357. END;
  358.  
  359. /
  360.  
  361. /
  362.  
  363. -- SOLUTIONS
  364.  
  365. SET SERVEROUTPUT ON SIZE 20000 FORMAT WORD_WRAPPED;
  366.  
  367. SELECT COUNT(*)
  368. FROM BUG
  369. WHERE STATUS='ACTIVE' AND U_ID=3;
  370.  
  371. CREATE OR REPLACE
  372. FUNCTION CREATE_ANNOTATION (userId IN ANNOTATION.U_ID%TYPE, bugId IN ANNOTATION.B_ID%TYPE, info IN ANNOTATION.INFO%TYPE)
  373. RETURN ANNOTATION.ID%TYPE IS
  374. created_id ANNOTATION.ID%TYPE := -1;
  375. CURSOR CREATED (userId IN ANNOTATION.U_ID%TYPE, bugId IN ANNOTATION.B_ID%TYPE, info IN ANNOTATION.INFO%TYPE) IS
  376. SELECT ID
  377. FROM ANNOTATION
  378. WHERE B_ID=bugId AND U_ID=userId AND INFO=info;
  379.  
  380. CURSOR VALID_CHECK_SUPERUSER (userId IN ANNOTATION.U_ID%TYPE) IS
  381. SELECT TYPE
  382. FROM USERS
  383. WHERE ID=userId;
  384.  
  385. userRole USERS.ID%TYPE := -1;
  386.  
  387. CURSOR BUG_OWNER (bugId IN ANNOTATION.B_ID%TYPE) IS
  388. SELECT U_ID
  389. FROM bug
  390. WHERE ID=bugId;
  391.  
  392. bugOwner BUG.U_ID%TYPE := -1;
  393.  
  394. CURSOR ACTIVE_COUNT (userId IN ANNOTATION.U_ID%TYPE) IS
  395. SELECT ID
  396. FROM BUG
  397. WHERE STATUS='ACTIVE' AND U_ID=userId;
  398.  
  399. activeCount BUG.ID%TYPE := 0;
  400.  
  401. CURSOR BUG_STATUS (bugId IN ANNOTATION.B_ID%TYPE) IS
  402. SELECT STATUS
  403. FROM BUG
  404. WHERE ID=bugId;
  405.  
  406. bugStatus BUG.STATUS%TYPE := '';
  407.  
  408. fk_violation_exception EXCEPTION;
  409. PRAGMA exception_init (fk_violation_exception, -2291);
  410. BEGIN
  411. OPEN VALID_CHECK_SUPERUSER(userId);
  412. FETCH VALID_CHECK_SUPERUSER INTO userRole;
  413. CLOSE VALID_CHECK_SUPERUSER;
  414.  
  415. IF (userRole != 0) THEN
  416. OPEN BUG_OWNER(bugId);
  417. FETCH BUG_OWNER INTO bugOwner;
  418. CLOSE BUG_OWNER;
  419. IF (bugOwner != userId) THEN
  420. RAISE_APPLICATION_ERROR(-20001, 'USER ' || userId || ' is not authorized to modify this issue!');
  421. END IF;
  422. END IF;
  423.  
  424. OPEN ACTIVE_COUNT(userId);
  425. FETCH ACTIVE_COUNT INTO activeCount;
  426. CLOSE ACTIVE_COUNT;
  427.  
  428. IF (activeCount != 1 AND userRole != 0)
  429. THEN RAISE_APPLICATION_ERROR(-20001, 'USER ' || userId || ' has no/more than one active issue(s)!');
  430. END IF;
  431.  
  432. OPEN BUG_STATUS(bugId);
  433. FETCH BUG_STATUS INTO bugStatus;
  434. CLOSE BUG_STATUS;
  435.  
  436. IF (bugStatus != 'ACTIVE')
  437. THEN RAISE_APPLICATION_ERROR(-20001, 'ISSUE ' || bugId || ' is not ACTIVE!');
  438. END IF;
  439.  
  440. INSERT INTO ANNOTATION (B_ID, U_ID, INFO)
  441. VALUES (bugId, userId, info);
  442.  
  443. OPEN CREATED(userId, bugId, info);
  444. FETCH CREATED INTO created_id;
  445. CLOSE CREATED;
  446. RETURN created_id;
  447. EXCEPTION
  448. WHEN fk_violation_exception THEN
  449. IF SQLERRM LIKE '%(STATIA01.ANNOTATION_BUG_FK1)%'
  450. THEN RAISE_APPLICATION_ERROR(-20001, 'ISSUE with id ' || bugId || ' does not exist!');
  451. ELSIF SQLERRM LIKE '%(STATIA01.ANNOTATION_USERS_FK1)%'
  452. THEN RAISE_APPLICATION_ERROR(-20001, 'USER with id ' || userId || ' does not exist!');
  453. ELSE RAISE;
  454. END IF;
  455. END;
  456.  
  457. DECLARE
  458. newAnnotationId ANNOTATION.ID%TYPE;
  459. BEGIN
  460. --newAnnotationId := CREATE_ANNOTATION (-21, 1, 'ANNOTATIONTEXT'); -- MISSING USERID
  461. --newAnnotationId := CREATE_ANNOTATION (3, -2, 'ANNOTATIONTEXT'); -- MISSING BUG
  462. --newAnnotationId := CREATE_ANNOTATION (3, 2, 'ANNOTATIONTEXT'); -- CLOSED BUG
  463. --newAnnotationId := CREATE_ANNOTATION (3, 1, 'ANNOTATIONTEXT2'); -- VALID
  464. --newAnnotationId := CREATE_ANNOTATION (2, 1, 'ADMIN_WAS_HERE'); -- VALID, AS 2 IS ADMIN
  465. newAnnotationId := CREATE_ANNOTATION (4, 1, 'NON_ADMIN_WAS_HERE'); -- SHOULD FAIL, AS 4 IS NOT ADMIN
  466. dbms_output.put_line(newAnnotationId);
  467. END;
  468.  
  469. SELECT B.ID, B.U_ID, B.INFO
  470. FROM ANNOTATION B
  471. WHERE B.B_ID=1;
  472.  
  473. CREATE OR REPLACE
  474. PROCEDURE FIND_CLOSED_ISSUES (userId IN BUG.U_ID%TYPE)
  475. IS
  476. CURSOR CLOSED (userId IN BUG.U_ID%TYPE) IS
  477. SELECT B.ID, B.NAME, B.U_ID
  478. FROM BUG B
  479. WHERE B.U_ID=userId AND B.STATUS='CLOSED';
  480.  
  481. CURSOR ANNOTATIONS_BY_BUG (bugId IN BUG.ID%TYPE) IS
  482. SELECT A.ID, A.U_ID, A.INFO
  483. FROM ANNOTATION A
  484. WHERE A.B_ID=bugId;
  485.  
  486. bugId BUG.ID%TYPE;
  487. bugName BUG.NAME%TYPE;
  488. bugOwner BUG.U_ID%TYPE;
  489. annotationId ANNOTATION.ID%TYPE;
  490. annotationUser ANNOTATION.U_ID%TYPE;
  491. annotationInfo ANNOTATION.INFO%TYPE;
  492. BEGIN
  493. OPEN CLOSED(userId);
  494. LOOP
  495. FETCH CLOSED INTO bugId, bugName, bugOwner;
  496. EXIT WHEN CLOSED%NOTFOUND;
  497. dbms_output.put_line('BUG: ' || bugId || ', called: ' || bugName || ' was created by user: ' || bugOwner);
  498. OPEN ANNOTATIONS_BY_BUG(bugId);
  499. LOOP
  500. FETCH ANNOTATIONS_BY_BUG INTO annotationId, annotationUser, annotationInfo;
  501. EXIT WHEN ANNOTATIONS_BY_BUG%NOTFOUND;
  502. dbms_output.put_line(' ANNOTATION: ' || annotationId || ', with info: ' || annotationInfo || ' was created by user: ' || annotationUser);
  503. END LOOP;
  504. CLOSE CLOSED;
  505. END LOOP;
  506. CLOSE CLOSED;
  507. END;
  508.  
  509. BEGIN
  510. FIND_CLOSED_ISSUES(3);
  511. END;
Add Comment
Please, Sign In to add comment