1. Trang chủ
  2. » Công Nghệ Thông Tin

Oracle Built−in Packages- P135 ppsx

5 237 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 80,07 KB

Nội dung

The replication group must already exist and be quiesced. 15.3.3.3.3 Examples The following call removes table SPROCKET.PRODUCTS from the SPROCKET replication group, but preserves the table: BEGIN DBMS_REPCAT.DROP_MASTER_REPOBJECT( sname => 'SPROCKET', oname => 'PRODUCTS', type => 'TABLE'); END; Dropping a table from a replication group automatically drops all replication triggers associated with the table and removes it from the replication data dictionary views. The DROP_MASTER_REPOBJECT procedure can remove the object from the replication group, and also drop the object from the schema by setting the drop_objects parameter to TRUE, as shown in this example: BEGIN DBMS_REPCAT.DROP_MASTER_REPOBJECT( sname => 'SPROCKET', oname => 'PRODUCTS', type => 'TABLE', drop_objects => TRUE); END; 15.3.3.4 The DBMS_REPCAT.EXECUTE_DDL procedure DBMS_REPCAT.CREATE_MASTER_REPOBJECT and DBMS_REPCAT.DROP_MASTER_REPOBJECT do not support every type of object. For example, you cannot use these procedures to drop and create constraints. Enter DBMS_REPCAT's EXECUTE_DDL procedure. The EXECUTE_DDL procedure allows you to perform DDL at multiple sites. The specification follows: PROCEDURE DBMS_REPCAT.EXECUTE_DDL (gname IN VARCHAR2 := '', {master_list IN VARCHAR2 := NULL, | master_table IN dbms_utility.dblink_array,} ddl_text IN VARCHAR2, sname IN VARCHAR2 := ''); Parameters are summarized in the following table. Name Description gname Name of the replicated object group. master_list Comma−separated string of master site global names at which DDL is to be performed. If NULL (the default), DDL is applied at all master sites in the replication group. Use either parameter master_list or master_table. master_table PL/SQL table of master site global names at which DDL is to be performed. Use either parameter master_list or master_table. ddl_text DDL statement to apply. [Appendix A] What's on the Companion Disk? 15.3.3 Replicated Objects with DBMS_REPCAT 661 sname Not used. 15.3.3.4.1 Exceptions The EXECUTE_DDL procedure may raise the following exceptions: Name Number Description commfailure −23317 Unable to communicate with master site ddlfailure −23318 Unable to perform DDL nonmaster −23312 At least one site in master_list or master_table is not a master site nonmasterdef −23312 Calling site is not a master definition site 15.3.3.4.2 Restrictions Note the following restrictions on calling EXECUTE_DDL: • This procedure must be called from the master definition site. • The replication group must already exist. NOTE: The environment does not have to be quiesced. 15.3.3.4.3 Example This example creates an index on the SPROCKET.STATES table at sites D7CA.BIGWHEEL.COM and D7NY.BIGWHEEL.COM. Note that as in the example of CREATE_MASTER_REPOBJECT, we must specify the schema in which to create the index. DECLARE vMasters VARCHAR2(30); BEGIN vMasters := 'D7CA.BIGWHEEL.COM,D7NY.BIGWHEEL.COM'; DBMS_REPCAT.EXECUTE_DDL( gname => 'SPROCKET', master_list => vMasters, ddl_text =>'CREATE INDEX sprocket.i_state_id ON sprocket.tstates(state_id)', sname =>'SPROCKET'); END; 15.3.3.5 The DBMS_REPCAT.ALTER_MASTER_REPOBJECT procedure Just as you can propagate DDL to create objects with the EXECUTE_DDL procedure, you can also propagate DDL to alter objects with DBMS_REPCAT.ALTER_MASTER_REPOBJECT. Unlike EXECUTE_DDL, ALTER_MASTER_REPOBJECT does not allow you to specify a list of master sites; the call affects all masters. In other words, Oracle does not support site−specific customizations of replicated objects. The specification follows: PROCEDURE DBMS_REPCAT.ALTER_MASTER_REPOBJECT (sname IN VARCHAR2, oname IN VARCHAR2, type IN VARCHAR2, ddl_text IN VARCHAR2, comment IN VARCHAR2 := '', retry IN BOOLEAN := FALSE); [Appendix A] What's on the Companion Disk? 15.3.3 Replicated Objects with DBMS_REPCAT 662 Parameters are summarized in the following table. Name Description sname Name of the schema to which object oname belongs. oname Name of the object to alter. type The oname object type. Supported types: FUNCTION, INDEX, PACKAGE, PACKAGE BODY, SYNONYM, TABLE, TRIGGER, and VIEW. ddl_text Text of DDL statement to apply. comment Comment visible in DBA_REPOBJECT data dictionary view. retry If set to TRUE, procedure alters only objects whose status is not VALID at master sites. 15.3.3.5.1 Exceptions The ALTER_MASTER_REPOBJECT procedure may raise the following exceptions: Name Number Description commfailure −23317 Unable to communicate with one or more master site(s) ddlfailure −23318 DDL at master definition site failed missingobject −23308 Object oname does not exist nonmasterdef −23312 Calling site is not the master definition site notquiesced −23310 Replication group gname is not quiesced typefailure −23319 DDL on objects of type type is not supported 15.3.3.5.2 Restrictions Note the following restrictions on calling ALTER_MASTER_REPOBJECT: • This procedure must be run from the master definition site. • The replication group must be quiesced. • You must call DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT for the altered object before resuming replication. 15.3.3.5.3 Example If you set the retry parameter to TRUE, ALTER_MASTER_REPOBJECT applies the DDL only at sites where the object has a status of INVALID in the DBA_OBJECTS data dictionary view. BEGIN DBMS_REPCAT.ALTER_MASTER_REPOBJECT( sname => 'SPROCKET', oname => 'PRODUCTMAINT', type => 'PACKAGE BODY' ddl_text => 'ALTER PACKAGE SPROCKET.PRODUCTMAINT COMPILE BODY', comment => 'Recompiled on '||sysdate|| ' by '||user, retry => TRUE ); END; [Appendix A] What's on the Companion Disk? 15.3.3 Replicated Objects with DBMS_REPCAT 663 Notice that we specify the schema for the object that we are altering. As with DBMS_REPCAT.EXECUTE_DDL, the ALTER_MASTER_REPOBJECT procedure operates on objects in the caller's schema by default, and the caller is generally the replication administrator account, not the schema account. This example alters the width of the state_id column in table SPROCKET.STATES at all sites: BEGIN DBMS_REPCAT.ALTER_MASTER_REPOBJECT( sname => 'SPROCKET', oname => 'PRODUCTMAINT', type => 'PACKAGE BODY' ddl_text => 'ALTER TABLE SPROCKET.STATES MODIFY (STATE_ID NUMBER(10))' , comment => 'state_id widened on '||sysdate|| ' by '||user); END; 15.3.3.6 The DBMS_REPCAT.COMMENT_ON_REPOBJECT procedure As you have seen in the previous examples, you can associate comments with a replicated object when you create or alter it by passing a VARCHAR2 string to the comment parameter. You can see these comments in the object_comment field of DBA_REPOBJECTS. You can also create comments without creating or altering the object with DBMS_REPCAT's COMMENT_ON_REPOBJECT procedure. The specification follows: PROCEDURE DBMS_REPCAT.COMMENT_ON_REPOBJECT (sname IN VARCHAR2, oname IN VARCHAR2, type IN VARCHAR2, comment IN VARCHAR2); Parameters are summarized in the following table. Name Description sname Name of schema to which object belongs oname Name of the object type Object type comment Comment 15.3.3.6.1 Exceptions The COMMENT_ON_REPOBJECT procedure may raise the following exceptions: Name Number Description commfailure −23317 Unable to communicate with one or more master sites missingobject −23308 Object oname does not exist nonmasterdef −23312 Calling site is not master definition site typefailure −23319 Object type is not supported [Appendix A] What's on the Companion Disk? 15.3.3 Replicated Objects with DBMS_REPCAT 664 15.3.3.6.2 Restrictions The COMMENT_ON_REPOBJECT procedure must be called from the master definition site. 15.3.3.6.3 Example The following call updates the comment for replicated table SPROCKET.PRICES: BEGIN DBMS_REPCAT.COMMENT_ON_REPOBJECT( sname => 'SPROCKET', − oname => 'PRICES', − type => 'TABLE', − comment => 'Headquarters updates this table once a month.'); END; 15.3.4 Replication Support with DBMS_REPCAT The next step in the creation of a replicated environment is to generate replication support for your replicated tables, packages, and package bodies. In the case of replicated tables, this step creates a BEFORE ROW trigger, called tablename$RT, and three packages: tablename$RP tablename$RR tablename$TP This code propagates DML to remote sites, and applies DML on behalf of remote sites. We'll examine this code in the examples of these procedures: DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT DBMS_REPCAT.GENERATE_REPLICATION_PACKAGE DBMS_REPCAT.GENERATE_REPLICATION_TRIGGER 15.3.4.1 The DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT procedure The GENERATE_REPLICATION_SUPPORT procedure generates support for replicated tables, packages, and package bodies. The specifications differ for Oracle7 and Oracle8 as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (sname IN VARCHAR2, oname IN VARCHAR2, type IN VARCHAR2, package_prefix IN VARCHAR2 := NULL, procedure_prefix IN VARCHAR2 := NULL, distributed IN BOOLEAN := TRUE, gen_objs_owner IN VARCHAR2 := NULL, gen_rep2_trigger IN BOOLEAN := FALSE); Here is the Oracle8 specification: PROCEDURE DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (sname IN VARCHAR2, oname IN VARCHAR2, type IN VARCHAR2, package_prefix IN VARCHAR2 := NULL, procedure_prefix IN VARCHAR2 := NULL, [Appendix A] What's on the Companion Disk? 15.3.3 Replicated Objects with DBMS_REPCAT 665 . replicated tables, packages, and package bodies. The specifications differ for Oracle7 and Oracle8 as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT . not allow you to specify a list of master sites; the call affects all masters. In other words, Oracle does not support site−specific customizations of replicated objects. The specification follows: PROCEDURE. TRUE, gen_objs_owner IN VARCHAR2 := NULL, gen_rep2_trigger IN BOOLEAN := FALSE); Here is the Oracle8 specification: PROCEDURE DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (sname IN VARCHAR2,

Ngày đăng: 07/07/2014, 00:20

TỪ KHÓA LIÊN QUAN