<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Parm Patram &#187; HACKING</title>
	<atom:link href="http://oracle.3dub.com/category/hacking/feed/" rel="self" type="application/rss+xml" />
	<link>http://oracle.3dub.com</link>
	<description>Oracle, Linux and UNIX tips, tricks and stuff</description>
	<lastBuildDate>Fri, 03 Feb 2012 18:14:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>V$ listing method</title>
		<link>http://oracle.3dub.com/2009/05/01/v-listing-method/</link>
		<comments>http://oracle.3dub.com/2009/05/01/v-listing-method/#comments</comments>
		<pubDate>Fri, 01 May 2009 18:15:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HACKING]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=332</guid>
		<description><![CDATA[1. ran query:
select VIEW_NAME from ALL_VIEWS WHERE (view_name like ‘V_$%’ or view_name like ‘V$%’) order by view_name; and saved to a text file (/tmp/vdollar.txt)
2. make a directory to work in:
mkdir VDOLLAR
3. change to that directory:
cd VDOLLAR
4. use shell to create scripts to login and run
DESC for each line in above file and save to an [...]]]></description>
			<content:encoded><![CDATA[<p>1. ran query:<br />
select VIEW_NAME from ALL_VIEWS WHERE (view_name like ‘V_$%’ or view_name like ‘V$%’) order by view_name; and saved to a text file (/tmp/vdollar.txt)</p>
<p>2. make a directory to work in:<br />
mkdir VDOLLAR</p>
<p>3. change to that directory:<br />
cd VDOLLAR</p>
<p>4. use shell to create scripts to login and run<br />
DESC for each line in above file and save to an individual file:<br />
for i in `cat /tmp/vdollar.txt `; do (echo &#8220;sqlplus / as sysdba &lt;&lt; EOF&#8221;; echo desc &#8216;V\$&#8217;${i}&#8217;;'; echo &#8220;EOF&#8221;) &gt; $i.sh; done</p>
<p>5. Now execute all of the scripts:<br />
for i in `ls *.sh`; do sh $i &gt; $i.txt; done</p>
<p>6. used perl to parse out the sqlplus header and footer in each of the files, then catt`ed everything together with the #### separators:<br />
#!/usr/bin/perl</p>
<p>@files=`ls *.sh.txt`;</p>
<p>foreach $file (@files){<br />
chomp $file;<br />
#print &#8220;FILE: $file\n&#8221;;<br />
($vdollar,undef,undef)=split(&#8217;\.&#8217;,$file);<br />
open(IN,&#8221;$file&#8221;) or die &#8220;unable to open $file: $!\n&#8221;;<br />
open(OUT,&#8221;&gt;$vdollar.txt&#8221;) or die &#8220;unable to open $vdollar.txt: $!\n&#8221;;<br />
$inside=&#8217;no&#8217;;<br />
$lnum=1;<br />
print OUT &#8220;V\$$vdollar\n&#8221;;<br />
while(&lt;IN&gt;){<br />
#print &#8220;File; $file: LINE: $lnum\n&#8221;;<br />
$l = $_;<br />
if ( $l =~ /&#8212;&#8212;&#8212;/ ){<br />
$inside = &#8216;yes&#8217;;<br />
}<br />
elsif ( $l =~ /^$/  &amp;&amp; $inside eq &#8216;yes&#8217; ){<br />
$inside = &#8216;no&#8217;; last;<br />
}<br />
elsif ( $inside eq &#8216;yes&#8217; ){<br />
print OUT $l;<br />
$lnum++;<br />
}<br />
}<br />
close OUT;<br />
close IN;<br />
# delete all of the zero line files<br />
if ( $lnum == 1 ){<br />
system (&#8221;rm -f $vdollar.txt&#8221;);<br />
}<br />
}</p>
<p>7. now remove all of the .sh.txt files (used by the perl program):<br />
rm -f  *.sh.txt</p>
<p>8. Cat everything together:<br />
for i in `ls *.txt`; do cat $i; echo; echo &#8216;#######################################################&#8217;; echo; done &gt; /tmp/all.txt</p>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2009/05/01/v-listing-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

