A few days ago, Roger's blog updated an article, which defines the dbms_rowid package. Oracle packages are all encrypted using wrap. Someone on itpub studied unwrap and published some code to implement unwrap.
For more information about wrap and unwrap, see my blog:
Oracle wrap and unwrap (encryption and decryption) Description
Http://blog.csdn.net/tianlesoftware/article/details/6698535
Rowid is also used in dB maintenance. It is helpful to understand the related functions of rowid.
Oracle rowid
Http://blog.csdn.net/tianlesoftware/article/details/5020718
The part posted by Roger is not only code, but not comments. Therefore, toad is used to pull out the comments. Paste it. You can also directly use SQL to view:
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
-- '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 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
--
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
--
--
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
-- 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 rowid,
Schema_name in varchar2,
Object_name in varchar2,
Conversion_type in integer)
Return number;
Pragma restrict_references (rowid_verify, wnds, wnps, rnps );
End;
/
Bytes -------------------------------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
WEAVER: http://weibo.com/tianlesoftware
Email: dvd.dba@gmail.com
Dba1 group: 62697716 (full); dba2 group: 62697977 (full) dba3 group: 62697850 (full)
Super DBA group: 63306533 (full); dba4 group: 83829929 (full) dba5 group: 142216823 (full)
Dba6 group: 158654907 (full) chat group: 40132017 (full) chat group 2: 69087192 (full)
-- Add the group to describe the relationship between Oracle tablespace and data files in the remarks section. Otherwise, the application is rejected.