Oracle 10g dbms_rowid 包源碼

來源:互聯網
上載者:User

前幾天Roger 的blog 更新了一篇文章,是DBMS_ROWID包的定義部分,Oracle 的包的都是用wrap 進行加密的。itpub上有人研究了unwrap,也公布了一些代碼,可以實現unwrap。

關於wrap和unwrap,參考我的blog:
Oracle wrap 和 unwrap( 加密與解密) 說明
http://blog.csdn.net/tianlesoftware/article/details/6698535

rowid在DB 維護中用的也是比較多。 瞭解ROWID 的相關函數,有助於工作。 
Oracle Rowid 介紹
http://blog.csdn.net/tianlesoftware/article/details/5020718

Roger貼的那部分沒有只有代碼,沒有注釋,所以這裡用Toad 把注釋部分也拉出來了。貼一下。也可以直接用SQL 查看:
SQL>select text from dba_source where name='DBMS_ROWID'; 

 

/* Formatted on2011/8/18 11:26:49 (QP5 v5.163.1008.3004) */

CREATE OR REPLACE PACKAGE SYS.DBMS_ROWID

IS

   ------------

   --  OVERVIEW

   --

   --  This package provides procedures to createROWIDs and to interpret

   --  their contents

 

   --  SECURITY

   --

   --  The execution privilege is granted to PUBLIC.Procedures in this

   --  package run under the caller security.

 

 

   ----------------------------

 

   ----------------------------

 

   --  ROWID TYPES:

   --

   --   RESTRICTED - Restricted ROWID

   --

   --   EXTENDED  - Extended ROWID

   --

   rowid_type_restricted    CONSTANT INTEGER := 0;

   rowid_type_extended      CONSTANT INTEGER := 1;

 

   --  ROWID VERIFICATION RESULTS:

   --

   --   VALID  - Valid ROWID

   --

   --   INVALID - Invalid ROWID

   --

   rowid_is_valid           CONSTANT INTEGER := 0;

   rowid_is_invalid         CONSTANT INTEGER := 1;

 

   --  OBJECT TYPES:

   --

   --   UNDEFINED - Object Number not defined (forrestricted ROWIDs)

   --

   rowid_object_undefined   CONSTANT INTEGER := 0;

 

   --  ROWID CONVERSION TYPES:

   --

   --   INTERNAL - convert to/from column of ROWIDtype

   --

   --   EXTERNAL - convert to/from string format

   --

   rowid_convert_internal   CONSTANT INTEGER := 0;

   rowid_convert_external   CONSTANT INTEGER := 1;

 

   --  EXCEPTIONS:

   --

   --ROWID_INVALID  - invalid rowid format

   --

   --ROWID_BAD_BLOCK - block is beyond end of file

   --

   ROWID_INVALID                     EXCEPTION;

   PRAGMA EXCEPTION_INIT (ROWID_INVALID, -1410);

   ROWID_BAD_BLOCK                   EXCEPTION;

   PRAGMA EXCEPTION_INIT (ROWID_BAD_BLOCK, -28516);

 

   --  PROCEDURES AND FUNCTIONS:

   --

 

   --

   --ROWID_CREATE constructs a ROWID from its constituents:

   --

   --rowid_type - type (restricted/extended)

   --object_number - data object number (rowid_object_undefined for restricted)

   --relative_fno - relative file number

   --block_number - block number in this file

   --file_number - file number in this block

   --

   FUNCTION rowid_create (rowid_type      IN NUMBER,

                          object_number   IN NUMBER,

                          relative_fno    IN NUMBER,

                          block_number    IN NUMBER,

                          ROW_NUMBER      IN NUMBER)

      RETURN ROWID;

 

   PRAGMA RESTRICT_REFERENCES (rowid_create, WNDS, RNDS, WNPS, RNPS);

 

   --

   --ROWID_INFO breaks ROWID into its components and returns them:

   --

   --rowid_in - ROWID to be interpreted

   --rowid_type - type (restricted/extended)

   --object_number - data object number (rowid_object_undefined for restricted)

   --relative_fno - relative file number

   --block_number - block number in this file

   -- file_number - file number in this block

   --ts_type_in - type of tablespace which this row belongs to

   --              'BIGFILE' indicates BigfileTablespace

   --              'SMALLFILE' indicates Smallfile(traditional pre-10i) TS.

   --              NOTE: These two are the onlyallowed values for this param

   --

   PROCEDURE rowid_info (rowid_in        IN     ROWID,

                         rowid_type         OUT NUMBER,

                         object_number      OUT NUMBER,

                         relative_fno       OUT NUMBER,

                         block_number       OUT NUMBER,

                         ROW_NUMBER         OUT NUMBER,

                         ts_type_in      IN     VARCHAR2 DEFAULT 'SMALLFILE');

 

   PRAGMA RESTRICT_REFERENCES (rowid_info, WNDS, RNDS, WNPS, RNPS);

 

   --

   --ROWID_TYPE returns the type of a ROWID (restricted/extended_nopart,..)

   --

   --row_id - ROWID to be interpreted

   --

   FUNCTION rowid_type (row_idIN ROWID)

      RETURN NUMBER;

 

   PRAGMA RESTRICT_REFERENCES (rowid_type, WNDS, RNDS, WNPS, RNPS);

 

   --

   --ROWID_OBJECT extracts the data object number from a ROWID.

   --ROWID_OBJECT_UNDEFINED is returned for restricted rowids.

   --

   --row_id - ROWID to be interpreted

   --

   FUNCTION rowid_object (row_idIN ROWID)

      RETURN NUMBER;

 

   PRAGMA RESTRICT_REFERENCES (rowid_object, WNDS, RNDS, WNPS, RNPS);

 

   --

   --ROWID_RELATIVE_FNO extracts the relative file number from a ROWID.

   --

   --row_id - ROWID to be interpreted

   --ts_type_in - type of tablespace which this row belongs to

   --

   FUNCTION rowid_relative_fno (row_id       IN ROWID,

                                ts_type_in   IN VARCHAR2 DEFAULT 'SMALLFILE')

      RETURN NUMBER;

 

   PRAGMA RESTRICT_REFERENCES (rowid_relative_fno, WNDS, RNDS, WNPS, RNPS);

 

   --

   --ROWID_BLOCK_NUMBER extracts the block number from a ROWID.

   --

   --row_id - ROWID to be interpreted

   --ts_type_in - type of tablespace which this row belongs to

   --

   --

   FUNCTION rowid_block_number (row_id       IN ROWID,

                                ts_type_in   IN VARCHAR2 DEFAULT 'SMALLFILE')

      RETURN NUMBER;

 

   PRAGMA RESTRICT_REFERENCES (rowid_block_number, WNDS, RNDS, WNPS, RNPS);

 

   --

   --ROWID_ROW_NUMBER extracts the row number from a ROWID.

   --

   --row_id - ROWID to be interpreted

   --

   FUNCTION rowid_row_number (row_id IN ROWID)

      RETURN NUMBER;

 

   PRAGMA RESTRICT_REFERENCES (rowid_row_number, WNDS, RNDS, WNPS, RNPS);

 

   --

   --ROWID_TO_ABSOLUTE_FNO extracts the relative file number from a ROWID,

   --which addresses a row in a given table

   --

   --row_id - ROWID to be interpreted

   --

   --schema_name - name of the schema which contains the table

   --

   --object_name - table name

   --

   FUNCTION rowid_to_absolute_fno (row_id        IN ROWID,

                                  schema_name   IN VARCHAR2,

                                  object_name   IN VARCHAR2)

      RETURN NUMBER;

 

   PRAGMA RESTRICT_REFERENCES (rowid_to_absolute_fno, WNDS, WNPS, RNPS);

 

   --

   --ROWID_TO_EXTENDED translates the restricted ROWID which addresses

   -- arow in a given table to the extended format. Later, it may be removed

   --from this package into a different place

   --

   --old_rowid - ROWID to be converted

   --

   --schema_name - name of the schema which contains the table (OPTIONAL)

   --

   --object_name - table name (OPTIONAL)

   --

   --conversion_type - rowid_convert_internal/external_convert_external

   --                   (whether old_rowid wasstored in a column of ROWID

   --                    type, or the characterstring)

   --

   FUNCTION rowid_to_extended (old_rowid         IN ROWID,

                               schema_name       IN VARCHAR2,

                               object_name       IN VARCHAR2,

                              conversion_type   IN INTEGER)

      RETURN ROWID;

 

   PRAGMA RESTRICT_REFERENCES (rowid_to_extended, WNDS, WNPS, RNPS);

 

   --

   --ROWID_TO_RESTRICTED translates the extnded ROWID into a restricted format

   --

   --old_rowid - ROWID to be converted

   --

   --conversion_type - internal/external (IN)

   --

   --conversion_type - rowid_convert_internal/external_convert_external

   --                   (whetherreturned rowid will be stored in a column of

   --                    ROWID type, or thecharacter string)

   --

   FUNCTION rowid_to_restricted (old_rowid         IN ROWID,

                                conversion_type   IN INTEGER)

      RETURN ROWID;

 

   PRAGMA RESTRICT_REFERENCES (rowid_to_restricted, WNDS, RNDS, WNPS, RNPS);

 

   --

   --ROWID_VERIFY verifies the ROWID. It returns rowid_valid or rowid_invalid

   --value depending on whether a given ROWID is valid or not.

   --

   --rowid_in - ROWID to be verified

   --

   --schema_name - name of the schema which contains the table

   --

   --object_name - table name

   --

   --conversion_type - rowid_convert_internal/external_convert_external

   --                   (whether old_rowid wasstored in a column of ROWID

   --                    type, or the characterstring)

   --

   FUNCTION rowid_verify (rowid_in          IN ROWID,

                          schema_name       IN VARCHAR2,

                          object_name       IN VARCHAR2,

                          conversion_type   IN INTEGER)

      RETURN NUMBER;

 

   PRAGMA RESTRICT_REFERENCES (rowid_verify, WNDS, WNPS, RNPS);

END;

/

 

 

 

 

 

 

-------------------------------------------------------------------------------------------------------

Blog: http://blog.csdn.net/tianlesoftware

Weibo: http://weibo.com/tianlesoftware

Email: dvd.dba@gmail.com

DBA1 群:62697716(滿);   DBA2 群:62697977(滿)  DBA3 群:62697850(滿)  

DBA 超級群:63306533(滿);  DBA4 群: 83829929(滿) DBA5群: 142216823(滿) 

DBA6 群:158654907(滿)  聊天 群:40132017(滿)   聊天2群:69087192(滿)

--加群需要在備忘說明Oracle資料表空間和資料檔案的關係,否則拒絕申請

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.