Saturday, March 20, 2010

Play with rowid_info

PROCEDURE ROWID_INFO
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
ROWID_IN ROWID IN
ROWID_TYPE NUMBER OUT
OBJECT_NUMBER NUMBER OUT
RELATIVE_FNO NUMBER OUT
BLOCK_NUMBER NUMBER OUT
ROW_NUMBER NUMBER OUT
TS_TYPE_IN VARCHAR2 IN DEFAULT



SQL> select object_id , object_name from dba_objects where owner='PERFSTAT' and object_name like 'TMP%';

OBJECT_ID
----------
OBJECT_NAME
--------------------------------------------------------------------------------------------------------------------------------
283365
TMP_LOG_HISTORY



SQL> select rowid from perfstat.TMP_LOG_HISTORY;

ROWID
------------------
AADNUcABYAAAXSKAAA


SQL> set serveroutput on
SQL> l
1 declare
2 my_rowid varchar2(200);
3 ts_type_in VARCHAR2(200);
4 rid_type number;
5 obj_num number;
6 file_num number;
7 block_num number;
8 row_num number;
9 begin
10 my_rowid:='AADNUcABYAAAXSKAAA';
11 ts_type_in:='SMALLFILE';
12 --dbms_rowid.rowid_info(my_rowid,rid_type, obj_num, file_num, block_num, row_num);
13 dbms_rowid.rowid_info(my_rowid,rid_type, obj_num, file_num, block_num, row_num,ts_type_in);
14 dbms_output.put_line ('object id is :'||to_char(obj_num));
15* end;
SQL> /
object id is :840988

PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.

SQL> select object_id,object_name from dba_objects where data_object_id=840988 ;

OBJECT_ID
----------
OBJECT_NAME
--------------------------------------------------------------------------------------------------------------------------------
283365
TMP_LOG_HISTORY




-- note taht data_object_id is not the same as object id