dbms_rowid之dbms_rowid.rowid_info儲存過程使用(in out)

wisdomone1發表於2010-06-27

 

 

ROWID_INFO Procedure

This procedure returns information about a ROWID, including its type (restricted or extended), and the components of the ROWID. This is a procedure, and it cannot be used in a SQL statement.

Syntax

DBMS_ROWID.ROWID_INFO (
   rowid_in         IN   ROWID, #輸入引數
   ts_type_in       IN   VARCHAR2 DEFAULT 'SMALLFILE',
   rowid_type       OUT  NUMBER,#下列幾個引數全是輸出 引數
   object_number    OUT  NUMBER,
   relative_fno     OUT  NUMBER,
   block_number     OUT  NUMBER,
   row_number       OUT  NUMBER);

Pragmas

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

Parameters

Table 90-8 ROWID_INFO Procedure Parameters

Parameter Description

rowid_in

ROWID to be interpreted. This determines if the ROWID is a restricted (0) or extended (1) ROWID.

ts_type_in

The type of the tablespace (bigfile/smallfile) to which the row belongs.

 

#擴充套件rowid與限制rowid

rowid_type

Returns type (restricted/extended).

 

object_number

Returns data object number (rowid_object_undefined for restricted).

relative_fno

Returns relative file number.

block_number

Returns block number in this file.

row_number

Returns row number in this block.

 

 

 

 

 

 

 

根據上面編寫dbms_rowid.rowid_info的plsql,對於要輸入與輸出的引數全要定義變數,預設引數可以不用定義對應變數

SQL> r
  1  declare
  2  v_rowid rowid;
  3  v_rowid_type number;
  4  v_object_number number;
  5  v_relative_fno number;
  6  v_block_number number;
  7  v_row_number number;
  8  begin
  9  select rowid into v_rowid from scott.emp where rownum<2;#得到輸入變數v_rowid,把它傳遞給dbms_rowid.rowid_info過程
 10  dbms_rowid.rowid_info(v_rowid,v_rowid_type,v_object_number,v_relative_fno,v_block_number,v_row_number);dbms_output.put_line('row id is: '||v_rowid);
 11  dbms_output.put_line('rowid type is: '||v_rowid_type);#此處測試僅顯示1-2個輸出引數,其它同理
 12* end;
row id is: AAAMlsAAEAAAAAfAAA
rowid type is: 1

PL/SQL procedure successfully completed.

SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-666426/,如需轉載,請註明出處,否則將追究法律責任。

相關文章