home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / po7_win / db / rdbms71 / dbmssnap.sql < prev    next >
Encoding:
Text File  |  1994-08-07  |  9.5 KB  |  227 lines

  1. Rem 
  2. Rem $Header: dbmssnap.sql 7010300.1 94/02/24 18:26:07 snataraj Generic<base> $ 
  3. Rem  
  4. Rem  Copyright (c) 1991 by Oracle Corporation 
  5. Rem    NAME
  6. Rem      dbmssnap.sql - utilities for snapshots
  7. Rem    DESCRIPTION
  8. Rem      See below
  9. Rem    RETURNS
  10. Rem
  11. Rem  MODIFIED
  12. Rem     rjenkins   02/17/94 -  adding defaults
  13. Rem     adowning   02/02/94 -  split file into public / private binary files
  14. Rem     rjenkins   01/13/94 -  adding rollback seg to refresh groups
  15. Rem     rjenkins   12/21/93 -  supporting import/export
  16. Rem     rjenkins   12/17/93 -  creating job queue
  17. Rem     rjenkins   11/02/93 -  adding explicit language flag to parse
  18. Rem     rjenkins   10/22/93 -  work even if name_tokenize does not work
  19. Rem     rjenkins   10/14/93 -  merge changes from branch k7010101
  20. Rem     rjenkins   10/12/93 -  moving comma_to_table to dbmsutil
  21. Rem     rjenkins   10/11/93 -  change default refresh method to NULL
  22. Rem     rjenkins   08/30/93 -  push deferred txn queues before refresh
  23. Rem     rjenkins   08/17/93 -  adding clear_refresh
  24. Rem     rjenkins   07/22/93 -  stop hardcoding foo, bar
  25. Rem     rjenkins   07/06/93 -  adding i_am_a_refresh
  26. Rem     ghallmar   05/02/93 -  add multi-table consistent refresh 
  27. Rem     mmoore     10/02/92 -  change pls_integer to binary_integer 
  28. Rem     rjenkins   06/02/92 -  changing comment types 
  29. Rem     rjenkins   02/12/92 -  more snapshot changes 
  30. Rem     rjenkins   11/25/91 -  Creation 
  31. -----------------------------------------------------------------------
  32.  
  33. Rem
  34. Rem  Headers
  35. Rem
  36.  
  37. CREATE OR REPLACE PACKAGE dbms_snapshot IS
  38.  
  39.   ------------
  40.   --  OVERVIEW
  41.   --
  42.   --  These routines allow the user to refresh snapshots and purge logs.
  43.  
  44.   ------------------------------------------------
  45.   --  SUMMARY OF SERVICES PROVIDED BY THIS PACKAGE
  46.   --
  47.   --  purge_log        - purge log of unnecessary rows
  48.   --  refresh        - refresh a given snapshot
  49.   --  refresh_all    - refresh all snapshots that are due
  50.   --                to be refreshed
  51.   --  drop_snapshot    - drop a given snapshot
  52.   --  set_up        - prepare master site to refresh a snapshot
  53.   --  wrap_up        - record a refresh at the master site
  54.   --  get_log_age    - find oldest date entry in log
  55.   --  testing        - test snapshots (currently null)
  56.   --  I_am_a_refresh    - flag used to let triggers identify refreshes
  57.  
  58.  
  59.   ----------------------------
  60.   --  PROCEDURES AND FUNCTIONS
  61.   --
  62.   PROCEDURE purge_log( master VARCHAR2, num BINARY_INTEGER DEFAULT 1, 
  63.                        flag VARCHAR2 DEFAULT 'NOP' );
  64.  
  65.   PROCEDURE refresh( list                 IN VARCHAR2,
  66.                      method               IN VARCHAR2 DEFAULT NULL,
  67.                      rollback_seg         IN VARCHAR2 DEFAULT NULL,
  68.                      push_deferred_rpc    IN BOOLEAN DEFAULT TRUE,
  69.                      refresh_after_errors IN BOOLEAN DEFAULT FALSE );
  70.  
  71.   --  -----------------------------------------------------------------------
  72.   --  Transaction consistent refresh of an array of snapshots
  73.   --
  74.   --  The snapshots are refreshed atomically and consistently. 
  75.   --  Atomically: all snapshots are refreshed or none are.
  76.   --  Consistently: all integrity constraints that hold among master tables 
  77.   --    will hold among the snapshot tables. 
  78.   --  The "method" string (not required) should contain a letter for each 
  79.   --    of the snapshots in the array according to the following codes:
  80.   --    '?' -- use fast refresh when possible
  81.   --    'F' -- use fast refresh or raise an error if not possible
  82.   --    'C' -- perform a complete refresh, copying the entire snapshot from
  83.   --           the master
  84.   --    The default method for refreshing a snapshot is the method stored for
  85.   --      that snapshot in the data dictionary.
  86.   --  The maximum allowed value of "num_snapshots" is 100.
  87.   PROCEDURE refresh( tab                  IN OUT dbms_utility.uncl_array,
  88.                      method               IN VARCHAR2 DEFAULT NULL,
  89.                      rollback_seg         IN VARCHAR2 DEFAULT NULL,
  90.                      push_deferred_rpc    IN BOOLEAN DEFAULT TRUE,
  91.                      refresh_after_errors IN BOOLEAN DEFAULT FALSE );
  92.   --  External
  93.  
  94.   PROCEDURE refresh_all;
  95.   --  External, refresh all snapshots due to be refreshed
  96.   --  Requires ALTER ANY SNAPSHOT privilege
  97.  
  98.   PROCEDURE drop_snapshot( mowner VARCHAR2, master VARCHAR2, snapshot date);
  99.   --  Internal
  100.  
  101.   PROCEDURE set_up( mowner VARCHAR2, master VARCHAR2, log IN OUT VARCHAR2,
  102.                 snapshot IN OUT date, snaptime IN OUT date);
  103.   --  Internal
  104.  
  105.   PROCEDURE wrap_up( mowner VARCHAR2, master VARCHAR2, 
  106.                      sshot date, stime date);
  107.   --  Internal
  108.  
  109.   PROCEDURE get_log_age( oldest IN OUT date, mow VARCHAR2, mas VARCHAR2);
  110.   --  Internal
  111.  
  112.   PROCEDURE testing;
  113.  
  114.   I_am_a_refresh BOOLEAN := FALSE;
  115.  
  116. END dbms_snapshot;
  117. /
  118.  
  119. grant execute on dbms_snapshot to public
  120. /
  121. drop public synonym dbms_snapshot
  122. /
  123. create public synonym dbms_snapshot for dbms_snapshot
  124. /
  125.  
  126. CREATE OR REPLACE PACKAGE dbms_refresh IS
  127.   -- dbms_refresh is the interface for administering refresh groups.
  128.  
  129.   -- PARAMETERS:
  130.   -- NAME is of the form 'foo' or 'user.foo' or '"USER"."FOO"'.  
  131.   --   The logged-in user is used as a default.
  132.   -- LIST is a comma-separated list of objects to be refreshed, such as
  133.   --     'foo, scott.bar ,"SCOTT"."BLUE"'.  The default user is the owner
  134.   --     of the refresh group.
  135.   -- TAB  is a PL/SQL table of objects to be refreshed, starting with 1
  136.   --   and filling every number until an entry is NULL, with every entry
  137.   --   formatted the same way as NAME.  The default user is the owner
  138.   --   of the refresh group.
  139.   -- NEXT_DATE is the date for the refresh group to first be refreshed.
  140.   --   See dbmsjobq.sql .  If there is no current job, the default interval
  141.   --   will be 'null' and the job will delete itself after refreshing the
  142.   --   group at NEXT_DATE.
  143.   -- INTERVAL is used to determine the next NEXT_DATE.  See dbmsjobq.sql .
  144.   --   If there is no current job, NEXT_DATE will default to null and the
  145.   --   job will not run until you manually set NEXT_DATE to something else
  146.   --   or manually refresh the group.
  147.   -- IMPLICIT_DESTROY means to delete the refresh group when the last item
  148.   --   is subtracted from it.  The value is stored with the group definition.
  149.   --   Empty groups can be created with IMPLICIT_DESTROY set.
  150.  
  151.   aaspriv   BINARY_INTEGER;
  152.   -- Privilege number for ALTER ANY SNAPSHOT
  153.  
  154.   PROCEDURE make    ( name      IN VARCHAR2,
  155.                       list      IN VARCHAR2,
  156.                       next_date IN DATE,
  157.                       interval  IN VARCHAR2,
  158.                       implicit_destroy    IN BOOLEAN DEFAULT FALSE,
  159.                       lax       IN BOOLEAN DEFAULT FALSE,
  160.                       job       IN BINARY_INTEGER DEFAULT 0,
  161.                       rollback_seg  IN VARCHAR2 DEFAULT NULL,
  162.                       push_deferred_rpc    IN BOOLEAN DEFAULT TRUE,
  163.                       refresh_after_errors IN BOOLEAN DEFAULT FALSE );
  164.   PROCEDURE make    ( name      IN VARCHAR2,
  165.                       tab       IN dbms_utility.uncl_array,
  166.                       next_date IN DATE,
  167.                       interval  IN VARCHAR2,
  168.                       implicit_destroy    IN BOOLEAN DEFAULT FALSE,
  169.                       lax       IN BOOLEAN DEFAULT FALSE,
  170.                       job       IN BINARY_INTEGER DEFAULT 0,
  171.                       rollback_seg  IN VARCHAR2 DEFAULT NULL,
  172.                       push_deferred_rpc    IN BOOLEAN DEFAULT TRUE,
  173.                       refresh_after_errors IN BOOLEAN DEFAULT FALSE );
  174.   -- MAKE a new refresh group.
  175.  
  176.   PROCEDURE add     ( name      IN VARCHAR2,
  177.                       list      IN VARCHAR2,
  178.                       lax       IN BOOLEAN  DEFAULT FALSE );
  179.   PROCEDURE add     ( name      IN VARCHAR2,
  180.                       tab       IN dbms_utility.uncl_array,
  181.                       lax       IN BOOLEAN  DEFAULT FALSE );
  182.   -- ADD some refreshable objects to a refresh group.
  183.  
  184.   PROCEDURE subtract( name      IN VARCHAR2,
  185.                       list      IN VARCHAR2,
  186.                       lax       IN BOOLEAN  DEFAULT FALSE );
  187.   PROCEDURE subtract( name      IN VARCHAR2,
  188.                       tab       IN dbms_utility.uncl_array,
  189.                       lax       IN BOOLEAN  DEFAULT FALSE );
  190.   -- SUBTRACT some refreshable objects from a refresh group.
  191.  
  192.   PROCEDURE destroy ( name      IN VARCHAR2 );
  193.   -- DESTROY a refresh group, make it cease to exist.
  194.  
  195.   PROCEDURE change( name                 IN VARCHAR2,
  196.                     next_date            IN DATE DEFAULT NULL,
  197.                     interval             IN VARCHAR2 DEFAULT NULL,
  198.                     implicit_destroy     IN BOOLEAN  DEFAULT NULL,
  199.                     rollback_seg         IN VARCHAR2 DEFAULT NULL,
  200.                     push_deferred_rpc    IN BOOLEAN DEFAULT NULL,
  201.                     refresh_after_errors IN BOOLEAN DEFAULT NULL);
  202.   -- Change any changeable pieces of the job that does the refresh
  203.  
  204.   PROCEDURE refresh ( name      IN VARCHAR2 );
  205.   -- Atomically, consistently refresh all objects in a refresh group now.
  206.   -- Clear the BROKEN flag for the job if the refresh succeeds
  207.  
  208.   PROCEDURE user_export( rg#  IN BINARY_INTEGER,
  209.                          mycall IN OUT VARCHAR2);
  210.   -- Produce the text of a call for recreating the given group
  211.  
  212.   PROCEDURE user_export_child( myowner IN     VARCHAR2,
  213.                                myname  IN     VARCHAR2,
  214.                                mytype  IN     VARCHAR2,
  215.                                mycall  IN OUT VARCHAR2);
  216.   -- Produce the text of a call for recreating the given group item
  217. END dbms_refresh;
  218. /
  219.  
  220. GRANT EXECUTE ON dbms_refresh TO PUBLIC
  221. /
  222. DROP PUBLIC SYNONYM dbms_refresh
  223. /
  224. CREATE PUBLIC SYNONYM dbms_refresh FOR dbms_refresh
  225. /
  226.  
  227.