Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. -----------------------------------------------------------------------------------
  2. --
  3. -- Name: PollEnd
  4. -- Purpose: PollEnd request signifies that the change entries identified with the current
  5. -- interval have been successfully entered into the store and forward database
  6. -- and can be deleted from the article log tables.
  7. -- Input:
  8. -- argLSN IN RAW(10) LSN from distributor that was associated
  9. -- with this poll interval
  10. -- Output:
  11. -- Notes: This request causes those entries of the article log tables represented in the
  12. -- Poll Table and having the current pollid to be deleted from both their article log
  13. -- tables and from the Poll Table. The last request value is updated to reflect a
  14. -- PollEnd request.
  15. --
  16. -----------------------------------------------------------------------------------
  17. PROCEDURE PollEnd
  18. (
  19. argLSN IN RAW
  20. )
  21. AS
  22. SQLCommand VARCHAR2(500);
  23. LogTable VARCHAR2(255);
  24. CurrentPollID NUMBER;
  25. TableIDs number_tab;
  26. InstanceIDs number_tab;
  27. IDCount BINARY_INTEGER;
  28. PublisherLSN RAW(10);
  29.  
  30. BEGIN
  31. -- Put the published tableIDs in a PL/SQL table of IDs
  32. HREPL.GetTableIDs(TableIDs, InstanceIDs);
  33.  
  34. -- Get the current Poll ID
  35. SELECT Publisher_CurrentPollid INTO CurrentPollID FROM HREPL_Publisher;
  36.  
  37. IDCount := TableIDs.COUNT;
  38. -- For each table represented in the ID list
  39. FOR id_ind IN 1 .. IDCount
  40. LOOP
  41.  
  42. LogTable := REPLACE( REPLACE(ArticleLogTemplate, MatchString, TO_CHAR(TableIDs(id_ind))),
  43. MatchStringY, TO_CHAR(InstanceIDs(id_ind)));
  44.  
  45. BEGIN
  46. -- Generate command to delete from the article log those entries appearing in the
  47. -- Poll Table with the current PollID
  48. SQLCommand := 'DELETE FROM ' || LogTable || ' l ' ||
  49. 'WHERE EXISTS (SELECT p.POLL_POLLID FROM HREPL_POLL p ' ||
  50. ' WHERE CHARTOROWID(l.ROWID) = p.Poll_ROWID ' ||
  51. ' AND p.Poll_PollID = :Pollid)';
  52.  
  53. HREPL.ExecuteCommandForPollID(SQLCommand, CurrentPollID);
  54.  
  55. EXCEPTION
  56. WHEN OTHERS THEN NULL;
  57. END;
  58. END LOOP;
  59.  
  60. FOR POLLID IN (SELECT CurrentPollid FROM DUAL)
  61. LOOP
  62. -- Delete from HREPL_Event those entries appearing in the Poll Table
  63. -- with the current PollID.
  64. DELETE FROM HREPL_Event e
  65. WHERE EXISTS (SELECT p.POLL_POLLID FROM HREPL_POLL p
  66. WHERE CHARTOROWID(e.ROWID) = p.Poll_ROWID
  67. AND p.Poll_PollID = POLLID.CurrentPollID);
  68.  
  69. -- Delete entries from the Poll Table having the current Pollid
  70. DELETE FROM HREPL_Poll
  71. WHERE Poll_PollID = POLLID.CurrentPollID;
  72. END LOOP;
  73.  
  74. -- Drop all views associated with articles that are marked as UnPublishPending.
  75. -- Note: We cannot perform these drops in UnPublish table, since UnPublish
  76. -- table can execute concurrently with PollBegin and the querying
  77. -- of published tables by the log reader. PollEnd, however, executes
  78. -- synchronously with respect to these activities, so can be used
  79. -- to cleanup log tables and views that are no longer needed.
  80. HREPL.CleanupLogsandViews;
  81.  
  82. -- Mark the last request as PollEnd, and update the Publisher LSN
  83. -- to reflect the LSN committed at the publisher.
  84. UPDATE HREPL_Publisher
  85. SET Publisher_PollInProcess = NoPollInProcess,
  86. Publisher_LSN = argLSN;
  87.  
  88. -- Commit transaction
  89. COMMIT;
  90.  
  91. EXCEPTION
  92. WHEN OTHERS THEN
  93. ROLLBACK;
  94. RAISE;
  95.  
  96. END PollEnd;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement