Oracle Built−in Packages- P147 docx

5 247 0
Oracle Built−in Packages- P147 docx

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

Thông tin tài liệu

A comma−delimited list of column names, or a PL/SQL table of column names. Use "*" to add all columns in the table to the column group. 16.2.3.1.1 Exceptions ADD_GROUPED_COLUMN may raise the following exceptions: Name Number Description nonmasterdef −23312 Invoking site is not master definition site missingobject −23308 Table oname does not exist missinggroup −23331 Column group column_group does not exist missingcolumn −23334 Column(s) specified do not exist in table oname duplicatecolumn −23333 Column(s) specified already exist in column_group missingschema −23306 Schema sname does not exist 16.2.3.1.2 Restrictions Note the following restrictions on calling ADD_GROUPED_COLUMN: • You must call this procedure from the quiesced master definition site. • You must regenerate replication support for the table after defining the column group with the GENERATE_REPLICATION_SUPPORT procedure. 16.2.3.1.3 Example In this example, we add the columns CATALOG_ID and DESCRIPTION to the column group CG_PRODUCT_MFG_COLS that we created in the MAKE_COLUMN_GROUP example: DECLARE cg_list DBMS_REPCAT.VARCHAR2(s); BEGIN cg_list(1) := 'CATALOG_ID'; cg_list(1) := 'DESCRIPTION'; DBMS_REPCAT.ADD_GROUPED_COLUMN(sname=> 'SPROCKET', oname => 'PRODUCTS ', column_group => 'CG_PRODUCT_MFG_COLS', list_of_column_names => cg_list); END; 16.2.3.2 The DBMS_REPCAT.DROP_GROUPED_COLUMN procedure The DROP_GROUPED_COLUMN procedure allows you to drop a column from a column group. Dropping a column from a column group is quite similar to adding one. Make sure, however, that none of your conflict resolution methods reference the column(s) that you are dropping. And as with the other procedures with a "list_of_column_names" parameter, you can pass "*" to the parameter to indicate all fields in table oname. Here's the specification: PROCEDURE DBMS_REPCAT.DROP_GROUPED_COLUMN (sname IN VARCHAR2, oname IN VARCHAR2, column_group IN VARCHAR2, {list_of_column_names IN VARCHAR2 | list_of_column_names IN dbms_repcat.varchar2s}); [Appendix A] What's on the Companion Disk? 16.2.3 Modifying Existing Column Groups 721 Note that you must specify only one of the list_of_column_names parameters. Parameters are summarized in the following table. Name Description sname Name of the schema that owns the replicated table oname Name of the table with the column_group column_group Name of the column_group from which column(s) will be dropped list_of_column_names A comma−delimited list of column names, or a PL/SQL table of column names 16.2.3.2.1 Exceptions The DROP_GROUPED_COLUMN procedure may raise the following exceptions: Name Number Description missinggroup −23331 Column group column_group does not exist missingobject −23308 Table oname does not exist missingschema −23306 Schema sname does not exist nonmasterdef −23312 Invoking site is not the master definition site 16.2.3.2.2 Restrictions Note the following restrictions on calling DROP_GROUPED_COLUMN: • You must not call this procedure from the quiesced master definition site. • You must regenerate replication support for the table after defining the column group with the GENERATE_REPLICATION_SUPPORT procedure. 16.2.3.2.3 Example The following example shows how to drop a column from an existing column group: BEGIN DBMS_REPCAT.DROP_GROUPED_COLUMN( sname => 'SPROCKET', oname => 'PRODUCTS', column_group => 'CG_PRODUCT_MFG_COLS', list_of_column_names => 'CATALOG_ID, DESCRIPTION'); END; 16.2.3.3 The DBMS_REPCAT.COMMENT_ON_COLUMN_GROUP procedure The COMMENT_ON_COLUMN_GROUP procedure adds or changes the comment associated with a column group. Here's the specification: PROCEDURE DBMS_REPCAT.COMMENT_ON_COLUMN_GROUP (sname IN VARCHAR2, oname IN VARCHAR2, column_group IN VARCHAR2, comment IN VARCHAR2); Parameters are summarized in the following table. [Appendix A] What's on the Companion Disk? 16.2.3 Modifying Existing Column Groups 722 Name Description sname Name of the schema to which the replicated table belongs oname Name of the replicated table containing the column group column_group Name of the column group comment Comment 16.2.3.3.1 Exceptions The COMMENT_ON_COLUMN_GROUP procedure may raise the following exceptions: Name Number Description missinggroup −23331 The column_group does not exist nonmasterdef −23312 Calling site is not the master definition site 16.2.3.3.2 Restrictions The COMMENT_ON_COLUMN_GROUP procedure must be called from the master definition site. 16.2.3.3.3 Example You can create or change the comment field in DBA_REPCOLUMN_GROUP with the COMMENT_ON_COLUMN_GROUP procedure, as the following example illustrates: BEGIN DBMS_REPCAT.COMMENT_ON_COLUMN_GROUP( sname => 'SPROCKET', oname => 'PRODUCTS', column_group => 'CG_PRODUCT_MFG_COLS', comment => 'Added catalog_id + desc on '||sysdate); 16.1 Getting Started with DBMS_REPCAT 16.3 Priority Groups with DBMS_REPCAT Copyright (c) 2000 O'Reilly & Associates. All rights reserved. [Appendix A] What's on the Companion Disk? 16.2.3 Modifying Existing Column Groups 723 Chapter 16 Conflict Resolution 16.3 Priority Groups with DBMS_REPCAT Priority groups allow you to determine the validity of data based on its value. The priority group conflict resolution technique is most effective for data that has a finite range of possible values, and that goes through this range in a specific order. 16.3.1 About Priority Groups Consider the products table: SQL>desc products Name Null? Type −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− −−−−−−−− −−−− PRODUCT_ID NOT NULL NUMBER(9) PRODUCT_TYPE NOT NULL NUMBER(6) CATALOG_ID NOT NULL VARCHAR2(15) DESCRIPTION NOT NULL VARCHAR2(30) REV_LEVEL NOT NULL VARCHAR2(15) PRODUCTION_DATE NOT NULL DATE PRODUCTION_STATUS NOT NULL VARCHAR2(12) AUDIT_DATE NOT NULL DATE AUDIT_USER NOT NULL VARCHAR2(30) GLOBAL_NAME NOT NULL VARCHAR2(20) The PRODUCTION_STATUS field in this table can only take on certain values: CONCEPT, DEVELOPMENT, BETA, PRODUCTION, and DISCONTINUED. In addition, products must go through this range of values in the order given. This concept of a sequential range of values is known as a workflow, and priority groups are designed to enforce the rules of a workflow in a replicated environment. Unlike column groups, which pertain to fields in a specific table, you can define a priority group for a specific column, which may appear in one or more tables. Once you define and configure a priority group, you can designate it to resolve update conflicts within a column group. The basic idea is that if a conflict arises, the row with the data corresponding to the higher priority in the workflow "wins." Use the following programs to create and maintain priority groups: DBMS_REPCAT.ADD_PRIORITY_<datatype> DBMS_REPCAT.ALTER_PRIORITY DBMS_REPCAT.ALTER_PRIORITY_<datatype> DBMS_REPCAT.COMMENT_ON_PRIORITY_GROUPS DBMS_REPCAT.DEFINE_PRIORITY_GROUPS DBMS_REPCAT.DROP_PRIORITY DBMS_REPCAT.DROP_PRIORITY_GROUP DBMS_REPCAT.DROP_PRIORITY_<datatype> 724 16.3.2 Creating, Maintaining, and Dropping Priority Groups DBMS_REPCAT's DEFINE_PRIORITY_GROUP and DROP_PRIORITY_GROUP procedures allow you to create and drop priority groups. You use the COMMENT_ON_PRIORITY_GROUP procedure to maintain the comment on the priority group. 16.3.2.1 The DBMS_REPCAT.DEFINE_PRIORITY_GROUP procedure The DEFINE_PRIORITY_GROUP procedure creates a new priority group. The specifications differ for Oracle7 and Oracle8 as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REPCAT.DEFINE_PRIORITY_GROUP (gname IN VARCHAR2 := '', pgroup IN VARCHAR2, datatype IN VARCHAR2, fixed_length IN INTEGER := NULL, comment IN VARCHAR2 := NULL, sname IN VARCHAR2 := ''); Here is the Oracle8 specification: PROCEDURE DBMS_REPCAT.DEFINE_PRIORITY_GROUP (gname IN VARCHAR2 := '', pgroup IN VARCHAR2, datatype IN VARCHAR2, fixed_length IN INTEGER := NULL, comment IN VARCHAR2 := NULL); Parameters are summarized in the following table. Name Description gname Name of the replication group containing the priority group. pgroup Name of the priority group. datatype Datatype for the value used in the priority group. Supported datatypes: • CHAR • NCHAR (Oracle8 only) • VARCHAR2 • NUMBER • DATE • RAW fixed_length Fixed length for values. Used only for datatype CHAR. [Appendix A] What's on the Companion Disk? 16.3.2 Creating, Maintaining, and Dropping Priority Groups 725 . DEFINE_PRIORITY_GROUP procedure creates a new priority group. The specifications differ for Oracle7 and Oracle8 as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REPCAT.DEFINE_PRIORITY_GROUP (gname. INTEGER := NULL, comment IN VARCHAR2 := NULL, sname IN VARCHAR2 := ''); Here is the Oracle8 specification: PROCEDURE DBMS_REPCAT.DEFINE_PRIORITY_GROUP (gname IN VARCHAR2 := '', . group. datatype Datatype for the value used in the priority group. Supported datatypes: • CHAR • NCHAR (Oracle8 only) • VARCHAR2 • NUMBER • DATE • RAW fixed_length Fixed length for values. Used only

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

Mục lục

    A. What's on the Companion Disk?

    1.1 The Power of Built-in Packages

    1.1.1 A Kinder , More Sharing Oracle

    1.2 Built-in Packages Covered in This Book

    1.3.1 What Is a Package?

    1.3.2 Controlling Access with Packages

    1.3.3 Referencing Built-in Package Elements

    1.3.4 Exception Handling and Built-in Packages

    1.3.5 Encapsulating Access to the Built-in Packages

    1.3.6 Calling Built-in Packaged Code from Oracle Developer/2000 Release 1

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan