{"id":160,"date":"2009-05-26T21:41:24","date_gmt":"2009-05-27T02:41:24","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=160"},"modified":"2011-07-06T09:40:57","modified_gmt":"2011-07-06T14:40:57","slug":"generating-values-from-block-dumps","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2009\/05\/26\/generating-values-from-block-dumps\/","title":{"rendered":"Generating values from block dumps"},"content":{"rendered":"<p>Today, I had to identify all rows on a given block.  I used DBMS_ROWID, but initially I wasn&#8217;t using it correctly.  I figured out what I should have been doing (below)&#8230;<\/p>\n<pre>\r\nselect work_id from xwc.frbr_holding_display partition(FRBR_HOLDING_DISPLAY_P12) where dbms_rowid.ROWID_BLOCK_NUMBER(rowid,'BIGFILE') > = 8566791\r\n<\/pre>\n<p>&#8230;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&#8230;<\/p>\n<pre>\r\nalter system dump datafile &1 block &2;\r\ngrep \"col  0\" trace_file > tmp.txt\r\npython blockdump.py tmp.txt\r\n<\/pre>\n<p>&#8230;where blockdump.py is below&#8230;<\/p>\n<pre>\r\n#!\/usr\/bin\/python\r\n#---------------------------------------------------------------------------\r\n#Author:        Steve Howard\r\n#Date:          March 23, 2009\r\n#Organization:  AppCrawler\r\n#Purpose:       Simple script to print integer equivalents of block dump values.\r\n#---------------------------------------------------------------------------\r\n\r\nimport fileinput\r\nimport string\r\nimport sys\r\n\r\nfor line in fileinput.input([sys.argv[1:][0]]):\r\n  dep=int(string.replace(string.split(string.split(line,\"]\")[1])[0],\"c\",\"\")) - 1\r\n  i=0\r\n  tot=0\r\n  exp=dep\r\n  for col in string.split(string.split(line,\"]\")[1]):\r\n    if i > 0:  \r\n      tot = tot + ((int(col, 16) - 1) * (100**exp))\r\n      exp = exp - 1\r\n    i = i + 1\r\n  print line.rstrip(\"\\n\") + \" converts to \" + str(tot)\r\n<\/pre>\n<p>You can then validate the output by using the dump function in the database, converted to base 16&#8230;<\/p>\n<pre>\r\nselect dump(&one_of_the_values_returned_above,16) from dual;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today, I had to identify all rows on a given block. I used DBMS_ROWID, but initially I wasn&#8217;t using it correctly. I figured out what I should have been doing (below)&#8230; select work_id from xwc.frbr_holding_display partition(FRBR_HOLDING_DISPLAY_P12) where dbms_rowid.ROWID_BLOCK_NUMBER(rowid,&#8217;BIGFILE&#8217;) > =&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2009\/05\/26\/generating-values-from-block-dumps\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,24,22,26],"tags":[9],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/160"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":17,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":162,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/160\/revisions\/162"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}