Today, I had to identify all rows on a given block. I used DBMS_ROWID, but initially I wasn’t using it correctly. I figured out what I should have been doing (below)…
select work_id from xwc.frbr_holding_display partition(FRBR_HOLDING_DISPLAY_P12) where dbms_rowid.ROWID_BLOCK_NUMBER(rowid,'BIGFILE') > = 8566791
…but in the meantime, I also ended up dumping the blocks and writing the following python script. This assumes the first column is a primary key or some other kind of unique identifier for the rows…
alter system dump datafile &1 block &2; grep "col 0" trace_file > tmp.txt python blockdump.py tmp.txt
…where blockdump.py is below…
#!/usr/bin/python
#---------------------------------------------------------------------------
#Author: Steve Howard
#Date: March 23, 2009
#Organization: AppCrawler
#Purpose: Simple script to print integer equivalents of block dump values.
#---------------------------------------------------------------------------
import fileinput
import string
import sys
for line in fileinput.input([sys.argv[1:][0]]):
dep=int(string.replace(string.split(string.split(line,"]")[1])[0],"c","")) - 1
i=0
tot=0
exp=dep
for col in string.split(string.split(line,"]")[1]):
if i > 0:
tot = tot + ((int(col, 16) - 1) * (100**exp))
exp = exp - 1
i = i + 1
print line.rstrip("\n") + " converts to " + str(tot)
You can then validate the output by using the dump function in the database, converted to base 16…
select dump(&one_of_the_values_returned_above,16) from dual;