<?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>Alexey Bokov's weblog &#187; oracle</title>
	<atom:link href="http://bokov.net/weblog/tag/oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://bokov.net/weblog</link>
	<description>Anything that interests me</description>
	<lastBuildDate>Tue, 21 Feb 2012 15:30:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to dump oracle table into tab separated text file ( csv )</title>
		<link>http://bokov.net/weblog/programming/how-to-dump-oracle-table-into-tab-separated-text-file-csv/</link>
		<comments>http://bokov.net/weblog/programming/how-to-dump-oracle-table-into-tab-separated-text-file-csv/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 18:35:57 +0000</pubDate>
		<dc:creator>Alexey Bokov</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[sqlplus]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://bokov.net/weblog/?p=237</guid>
		<description><![CDATA[My way &#8211; run sqlplus, spool in using html markup and convert this html onto text by using sed replacements. It works fast enought, and better than parse resulted text by spool without markup. Bash script which impelement it is under below #!/bin/bash # alexey bokov &#8211; http://bokov.net/weblog # script converts(spool=dump) oracle table onto tab [...]]]></description>
			<content:encoded><![CDATA[<p>My way &#8211; run sqlplus, spool in using html markup and convert this html onto text by using sed replacements. It works fast enought, and better than parse resulted text by spool without markup. Bash script which impelement it is under below <span id="more-237"></span></p>
<address> #!/bin/bash</address>
<address> # alexey bokov &#8211; http://bokov.net/weblog<br />
</address>
<address> # script converts(spool=dump) oracle table onto tab separated text file via spooling it html and convert html to text.</address>
<address> # strange way, but it works.</address>
<address>OUTPUT_TEXT_FILE=&#8221;./oracle_db.csv&#8221;</address>
<address>ORACLE_USER=USER<br />
ORACLE_PASSWORD=1234<br />
ORACLE_TABLE=MY_DATA<br />
HTML_FILE=&#8221;./dump.html&#8221;</address>
<address>ORACLE_QUERY=&#8221;./req.sql&#8221;</address>
<address>echo &#8220;set echo off&#8221; &gt; $ORACLE_QUERY<br />
echo &#8220;set markup html on&#8221; &gt;&gt; $ORACLE_QUERY<br />
echo &#8220;set linesize 500&#8243; &gt;&gt; $ORACLE_QUERY<br />
echo &#8220;set pagesize 0&#8243; &gt;&gt; $ORACLE_QUERY<br />
echo &#8220;set newpage 0&#8243; &gt;&gt; $ORACLE_QUERY<br />
echo &#8220;set termout off&#8221; &gt;&gt; $ORACLE_QUERY<br />
echo &#8220;spool $HTML_FILE&#8221; &gt;&gt; $ORACLE_QUERY<br />
echo &#8220;select * from $ORACLE_TABLE;&#8221; &gt;&gt; $ORACLE_QUERY<br />
echo &#8220;spool off&#8221; &gt;&gt; $ORACLE_QUERY<br />
echo &#8220;exit;&#8221; &gt;&gt; $ORACLE_QUERY</address>
<address>echo &#8220;Spool $ORACLE_TABLE onto $HTML_FILE ( take some time )&#8230;&#8221;<br />
sqlplus $ORACLE_USER/$ORACLE_PASSWORD @$ORACLE_QUERY</address>
<address>echo &#8220;Convert html onto text file ( take some time also )&#8230;&#8221;<br />
# replace all eol<br />
tr &#8216;\n&#8217; &#8216; &#8216; &lt; $HTML_FILE &gt; $OUTPUT_TEXT_FILE<br />
sed -i &#8216;s/<br />
/\n/g&#8217; $OUTPUT_TEXT_FILE<br />
sed -i &#8216;s/&lt;\/td&gt;/\t/g&#8217; $OUTPUT_TEXT_FILE</address>
<address># replace all most html tags<br />
sed -i &#8216;s/&lt;[^&gt;]*&gt;//g&#8217;  $OUTPUT_TEXT_FILE</address>
<address>#replace   &#8221; &amp;<br />
sed -i &#8216;s/ / /g&#8217; $OUTPUT_TEXT_FILE<br />
sed -i &#8216;s/&#8221;/&#8221;/g&#8217; $OUTPUT_TEXT_FILE<br />
sed -i &#8216;s/&amp;/-/g&#8217; $OUTPUT_TEXT_FILE</address>
<address>#cleanup<br />
rm $HTML_FILE<br />
rm $ORACLE_QUERY</address>
<address>echo &#8221; Done, check out $OUTPUT_TEXT_FILE for result&#8230;&#8221;</address>
]]></content:encoded>
			<wfw:commentRss>http://bokov.net/weblog/programming/how-to-dump-oracle-table-into-tab-separated-text-file-csv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

