home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / RSF72 / V7PUP.SQL < prev    next >
Encoding:
Text File  |  1995-07-31  |  4.0 KB  |  105 lines

  1. rem
  2. rem  $Header: pupbld.sql 3020101.1 94/09/28 17:47:13 jathomps Generic<base> $
  3. rem  Copyright (c) Oracle Corporation 1988, 1994.  All Rights Reserved.
  4. rem
  5. rem  +---------------------------------------------------------------------+
  6. rem  |  PUPBLD.SQL -- CREATE PRODUCT AND USER PROFILE TABLES               |
  7. rem  |                                                                     |
  8. rem  |  Connect as SYSTEM before running this script                       |
  9. rem  |                                                                     |
  10. rem  |  This script is used by the DBA to create the product_profile and   |
  11. rem  |  user_profile tables in the SYSTEM account.                         |
  12. rem  |  There are two views, product_privs and user_privs, which are what  |
  13. rem  |  a user will see as product_profile and user_profile.  They allow   |
  14. rem  |  the user to see (and in the case of user_profile, modify) only     |
  15. rem  |  their own privileges or profiles.                                  |
  16. rem  +---------------------------------------------------------------------+
  17.  
  18. rem  +---------------------------------------------------------------+
  19. rem  |  If PRODUCT_USER_PROFILE existed, use its values and drop it  |
  20. rem  +---------------------------------------------------------------+
  21.  
  22. drop synonym product_user_profile;
  23.  
  24. create table product_profile as
  25.   select product, userid, attribute, scope, numeric_value, char_value,
  26.   date_value from product_user_profile;
  27.  
  28. drop table product_user_profile;
  29.  
  30. alter table product_profile add (long_value long);
  31.  
  32. rem  +---------------------------------------+
  33. rem  |  Create PRODUCT_PROFILE from scratch  |
  34. rem  +---------------------------------------+
  35.  
  36. create table product_profile
  37. (
  38.   product        varchar2 (30) not null,
  39.   userid         varchar2 (30),
  40.   attribute      varchar2 (240),
  41.   scope          varchar2 (240),
  42.   numeric_value  decimal (15,2),
  43.   char_value     varchar2 (240),
  44.   date_value     date,
  45.   long_value     long
  46. );
  47.  
  48. rem  +----------------------------------------------------------+
  49. rem  |  Create the view PRODUCT_PRIVS and grant access to that  |
  50. rem  +----------------------------------------------------------+
  51.  
  52. create view product_privs as
  53.   select product, userid, attribute, scope,
  54.          numeric_value, char_value, date_value, long_value
  55.   from product_profile
  56.   where userid = 'PUBLIC' or user like userid;
  57.  
  58. grant select on product_privs to public;
  59. create public synonym product_profile for system.product_privs;
  60. create synonym product_user_profile for system.product_profile;
  61. create public synonym product_user_profile for system.product_privs;
  62.  
  63. rem  +---------------------------------+
  64. rem  |  Create the table USER_PROFILE  |
  65. rem  +---------------------------------+
  66.  
  67. create table user_profile
  68. (
  69.   product        varchar2 (30),
  70.   userid         varchar2 (30),
  71.   profile        varchar2 (240),
  72.   attribute      varchar2 (240),
  73.   numeric_value  decimal (15,2),
  74.   char_value     varchar2 (240),
  75.   date_value     date,
  76.   long_value     long
  77. );
  78.  
  79. grant select on user_profile to public;
  80.  
  81. rem  +-------------------------------------------------------+
  82. rem  |  Create the view USER_PRIVS and grant access to that  |
  83. rem  +-------------------------------------------------------+
  84.  
  85. create view user_privs as
  86.   select product, userid, profile, attribute,
  87.          numeric_value, char_value, date_value, long_value
  88.   from user_profile
  89.   where userid = user
  90.   with check option;
  91.  
  92. grant select, update, insert, delete on user_privs to public;
  93. create public synonym user_profile for system.user_privs;
  94.  
  95. rem  +-------------------------------------------------------------+
  96. rem  |  Update the one SRW attribute in the PRODUCT_PROFILE table  |
  97. rem  +-------------------------------------------------------------+
  98.  
  99. update system.product_profile set attribute = 'PAGE_LIMIT'
  100.   where product = 'SQL*ReportWriter' and attribute = 'LIMIT';
  101.  
  102. rem  +--------------------+
  103. rem  |  End of pupbld.sql |
  104. rem  +--------------------+
  105.