<?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>Ask the German &#187; Database</title>
	<atom:link href="http://www.askthegerman.com/archives/category/database/feed" rel="self" type="application/rss+xml" />
	<link>http://www.askthegerman.com</link>
	<description>"the owl of Minerva spreads its wings only with the falling of the dusk"</description>
	<lastBuildDate>Thu, 30 Apr 2009 10:26:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Extracting MySQL Data</title>
		<link>http://www.askthegerman.com/archives/241</link>
		<comments>http://www.askthegerman.com/archives/241#comments</comments>
		<pubDate>Mon, 22 Dec 2008 12:50:59 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Web Technologies]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[address book]]></category>
		<category><![CDATA[desc table]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[Gui]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[outfile]]></category>
		<category><![CDATA[statement]]></category>
		<category><![CDATA[use database]]></category>

		<guid isPermaLink="false">http://www.askthegerman.com/?p=241</guid>
		<description><![CDATA[Living in a world of GUIs (Graphical User Interface) many people are no longer aware about what SQL can do. Recently a friend asked me about, is it possible to extract the email adresses of my registered user out of my Joomla? Sure it is! It is not even difficult and the idea behind was [...]]]></description>
			<content:encoded><![CDATA[<p>Living in a world of GUIs (Graphical User Interface) many people are no longer aware about what SQL can do. Recently a friend asked me about, is it possible to extract the email adresses of my registered user out of my Joomla? Sure it is!</p>
<p>It is not even difficult and the idea behind was to load them into some email list to send out season greeting to all subscribers. To keep it simple here I will explain it by using a more common wordpress example, but in principle it can be done for any data the same way. </p>
<p>Most email clients are able to import a CSV (Comma separated List of Values) File by default, as also Excel or Access will &#8216;eat&#8217; them without problems.</p>
<p>Now we have to invoke the MySQL Command Line Client or any other tool which enables us to execute a&nbsp; SQL Statement hopefully we will ending up with such a prompt:</p>
<p><em>mysql&gt; </em></p>
<p>There we first tell MySQL&nbsp; to work with the specific database in question.</p>
<p><em>mysql&gt; use DATABASE</em> &nbsp; &nbsp; (e.q &nbsp; use wordpress)</p>
<p>With the command <em>desc</em> we can get a field description of our table.</p>
<p><em>mysql&gt; desc TABLENAME</em>&nbsp;&nbsp; (e.q.&nbsp; desc wp_users)</p>
<p>Knowing about the table structure now, with <em>select</em> we can extract the data wished:</p>
<p><em>mysql&gt; select user_nicename as Name,user_email as Email from wp_users;<br />        +&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />        | Name&nbsp; | Email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br />        +&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />        | admin | admin@localhost.com |<br />        +&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />        1 row in set (0.00 sec)</em></p>
<p>Seeing the output and being sure about the result will match our needs we are now finally going to spool the query result into a file:</p>
<p><em>mysql&gt; select user_nicename,user_email into outfile &#8216;c:/temp/u_emails.csv&#8217; fields terminated by &#8216;;&#8217; from wp_users;<br />        Query OK, 1 row affected (0.01 sec)</em> </p>
<p>Content of &quot;c:/temp/u_email.csv&quot;:</p>
<p><em>admin;admin@localhost.com</em></p>
<p>or as variation:</p>
<p>mysql&gt; select user_nicename,user_email into outfile &#8216;c:/temp/u_emails.txt&#8217; fields enclosed by &#8216;&quot;&#8217; terminated by &#8216;;&#8217; from wp_users;<br />        Query OK, 1 row affected (0.01 sec) </p>
<p>Content of &quot;c:/temp/u_email.csv&quot;:</p>
<p><em>&quot;admin&quot;;&quot;admin@localhost.com&quot;</em></p>
<p>And now it should be easy for you to import all emails addresses within your email client&#8217;s address book.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.askthegerman.com%2Farchives%2F241';
  addthis_title  = 'Extracting+MySQL+Data';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.askthegerman.com/archives/241/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RMAN Time Based Recovery</title>
		<link>http://www.askthegerman.com/archives/219</link>
		<comments>http://www.askthegerman.com/archives/219#comments</comments>
		<pubDate>Thu, 11 Dec 2008 09:45:26 +0000</pubDate>
		<dc:creator>Juergen</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Controlfile]]></category>
		<category><![CDATA[LIST INCARNATION]]></category>
		<category><![CDATA[ORA-00600]]></category>
		<category><![CDATA[RECOVERY]]></category>
		<category><![CDATA[RMAN]]></category>
		<category><![CDATA[TIME BASED]]></category>

		<guid isPermaLink="false">http://www.askthegerman.com/?p=219</guid>
		<description><![CDATA[Doing a repeated rman database time based recovery RMAN&#62; run{ &#8230; alter database mount; &#8230; set until time &#34;to_date(&#8217;27.10.2008 23:30:00&#8242;,&#8217;DD.MM.YYYY HH24:MI:SS&#8217;)&#34;; &#8230; restore database; recover database delete archivelog; alter database open resetlogs; } without rman catalog repository can fail with error: RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time To solve the issue [...]]]></description>
			<content:encoded><![CDATA[<p>Doing a repeated rman database time based recovery </p>
<p>RMAN&gt; <br />       run{<br />       &#8230;<br />       alter database mount;<br />       &#8230;<br />       set until time &quot;to_date(&#8217;27.10.2008 23:30:00&#8242;,&#8217;DD.MM.YYYY HH24:MI:SS&#8217;)&quot;;<br />       &#8230;<br />       restore database;<br />       recover database delete archivelog;<br />       alter database open resetlogs;<br />       }</p>
<p> without rman catalog repository can fail with error:</p>
<p>RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time</p>
<p>To solve the issue </p>
<ul>
<li>      list the incarnation id of the database</li>
</ul>
<p>RMAN&gt; list incarnation;</p>
<p>using target database control file instead of recovery catalog</p>
<p>List of Database Incarnations   </p>
<div align="left"><font face="Courier">DB&nbsp; Inc DB Name DB ID&nbsp;&nbsp;&nbsp; STATUS&nbsp; Reset SCN Reset Time<br />    Key Key<br />    </font></div>
<div align="left"></div>
<p align="left"><font face="Courier">  1&nbsp;&nbsp; 1&nbsp;&nbsp; ORAV10&nbsp; 76765624 PARENT&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 22.11.2007 16:44:40<br />       2&nbsp;&nbsp; 2&nbsp;&nbsp; ORAV10&nbsp; 76765624 PARENT&nbsp; 4921103&nbsp;&nbsp; 09.04.2008 11:38:07<br />       3&nbsp;&nbsp; 3&nbsp;&nbsp; ORAV10&nbsp; 76765624 ORPHAN&nbsp; 15854298&nbsp; 27.11.2008 11:43:33<br />       4&nbsp;&nbsp; 4&nbsp;&nbsp; ORAV10&nbsp; 76765624 CURRENT 15854298&nbsp; 27.11.2008 17:38:11</font></p>
<ul>
<li> set the database in mount status to incarnation id that is fitting to the selected restore time</li>
</ul>
<p>      &nbsp; <br />       RMAN&gt; shutdown immediate;<br />       RMAN&gt; startup mount;<br />       RMAN&gt; reset database to incarnation 2;</p>
<ul>
<li> repeat the database time based recovery</li>
</ul>
<p>Be careful: Do not restore controlfile. If you do so, incarnation is set the latest id and you run into same error.</p>
<p>RMAN&gt; list incarnation;</p>
<p>List of Database Incarnations   </p>
<div align="left"><font face="Courier">DB&nbsp; Inc DB Name DB ID&nbsp;&nbsp;&nbsp; STATUS&nbsp; Reset SCN Reset Time<br />   Key Key<br />   </font></div>
<div align="left"></div>
<p align="left"><font face="Courier">  1&nbsp;&nbsp; 1&nbsp;&nbsp; ORAV10&nbsp; 76765624 PARENT&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 22.11.2007 16:44:40<br />       2&nbsp;&nbsp; 2&nbsp;&nbsp; ORAV10&nbsp; 76765624 PARENT&nbsp; 4921103&nbsp;&nbsp; 09.04.2008 11:38:07<br />       5&nbsp;&nbsp; 5&nbsp;&nbsp; ORAV10&nbsp; 76765624 CURRENT 15783824&nbsp; 10.12.2008 16:03:56<br />       4&nbsp;&nbsp; 4&nbsp;&nbsp; ORAV10&nbsp; 76765624 ORPHAN&nbsp; 15854298&nbsp; 27.11.2008 17:38:11<br />       3&nbsp;&nbsp; 3&nbsp;&nbsp; ORAV10&nbsp; 76765624 ORPHAN&nbsp; 15854298&nbsp; 27.11.2008 11:43:33<br />       </font></p>
<p>In some cases you get errors during recovery<br />       ORA-00283: recovery session canceled due to errors<br />       ORA-00081: address range [0x60000000000A7D70, 0x60000000000A7D74) is not readable<br />       ORA-00600: internal error code, arguments: [kcvsor_current_inc_rdfail], [0], [], [], [], [], [], []</p>
<p>In this case you have to restore an adequate controlfile created in selected recovery time frame and that has the same incarnation as the datafiles (see also oracle support Note:378273.1) </p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.askthegerman.com%2Farchives%2F219';
  addthis_title  = 'RMAN+Time+Based+Recovery';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.askthegerman.com/archives/219/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transportable Tablespaces</title>
		<link>http://www.askthegerman.com/archives/210</link>
		<comments>http://www.askthegerman.com/archives/210#comments</comments>
		<pubDate>Wed, 10 Dec 2008 12:34:28 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[OSX]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[converting]]></category>
		<category><![CDATA[endianness Big]]></category>
		<category><![CDATA[endianness Little]]></category>
		<category><![CDATA[exp]]></category>
		<category><![CDATA[imp]]></category>
		<category><![CDATA[plattform]]></category>
		<category><![CDATA[RMAN]]></category>
		<category><![CDATA[transportable Tablespaces]]></category>

		<guid isPermaLink="false">http://www.askthegerman.com/?p=210</guid>
		<description><![CDATA[Since Oracle Version 10G ist is possible to transfer tablespaces no longer only between platforms of the same architecture. Now in 10G it also possible to transport from any platform to any platform, provided the platforms belong to the list below: SQL&#62;&#160; select * from v$transportable_platform; &#160;&#160; PLATFORM_ID PLATFORM_NAME&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ENDIAN_FORMAT &#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 1 Solaris[tm] OE [...]]]></description>
			<content:encoded><![CDATA[<p>Since Oracle Version 10G ist is possible to transfer tablespaces no longer only between platforms of the same architecture. Now in 10G it also possible to transport from any platform to any platform, provided the platforms belong to the list below:</p>
<p><em><font face="Courier">SQL&gt;&nbsp; select * from v$transportable_platform;</font></em></p>
<p><em><font face="Courier">&nbsp;&nbsp; PLATFORM_ID PLATFORM_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDIAN_FORMAT<br />        &nbsp;&nbsp; <br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 Solaris[tm] OE (32-bit)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Big<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 Solaris[tm] OE (64-bit)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Big<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7 Microsoft Windows NT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Little<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10 Linux IA (32-bit)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Little<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6 AIX-Based Systems (64-bit)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Big<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3 HP-UX (64-bit)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Big<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5 HP Tru64 UNIX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Little<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 HP-UX IA (64-bit)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Big<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11 Linux IA (64-bit)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Little<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 15 HP Open VMS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Little<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8 Microsoft Windows IA (64-bit)&nbsp;&nbsp;&nbsp; Little<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9 IBM zSeries Based Linux&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Big<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13 Linux 64-bit for AMD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Little<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16 Apple Mac OS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Big<br />        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12 Microsoft Windows 64-bit for AMD Little</font></em> </p>
<p><strong><span>But be aware that depending on which plattforms we deal with there might be some converting necessary or not<font face="courier">!</font></span></strong></p>
<p>To help you with that, I have carried together the little cook book about &quot;How to do&quot; below:</p>
<p><u>1. Set the tablespace to READ ONLY</u></p>
<p><em>SQL&gt; alter tablespace USERS read only;<br />       Tablespace altered.</em>&nbsp;</p>
<p>2. Export metadata</p>
<p><em>exp userid=\&#8217;/ as sysdba\&#8217; transport_tablespace=y<br />       tablespaces=users<br />       file=users_tts.dmp log=exp_users_tts.log<br />       statistics=none</em></p>
<p><u>3. Converting tablespace if necessary</u> </p>
<p>Depending on we have to convert the file between <strong>endianness Little</strong> and <strong>endianness Big</strong> (forward or backward) we can do that with RMAN:</p>
<p><em>rman target=/</em></p>
<p><em>Recovery Manager: Release 10.2.0.3.0 &#8211; Production on Wed Dec 10 13:10:57 2008<br />       connected to target database: orav10 (DBID=1953618181)</em></p>
<p><em>RMAN&gt; convert tablespace &#8216;USERS&#8217;<br />       2&gt;&nbsp; to platform=&quot;Linux IA (32-bit)&quot;<br />       3&gt;&nbsp; db_file_name_convert=&#8217;/database/orav10/datafiles/users.dbf&#8217;,<br />       4&gt;&nbsp; &#8216;/tmp/users.dbf&#8217;;</em></p>
<p><u>4. Move datafiles and export dump file</u></p>
<p><em>$ftp users_tts.dmp</em> </p>
<p>and <em>/database/orav10/datafiles/users.dbf</em> (no conversion)<br />   or <em>/tmp/users.dbf</em> (converted file if conversion had been required)</p>
<p><u>5. Import metadata</u> </p>
<p><em>imp userid=\&#8217;/ as sysdba\&#8217; TRANSPORT_TABLESPACE=Y <br />       datafiles=</em><em>/database/orav10/datafiles/users.dbf<br />       (or </em><em>/tmp/users.dbf )<br />       file=users_tts.dmp log=imp_users_tts.log</em> </p>
<p><u>6. Set the tablespace to READ WRITE</u></p>
<p><em>SQL&gt; alter tablespace USERS read write;<br />       Tablespace altered.</em>  </p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.askthegerman.com%2Farchives%2F210';
  addthis_title  = 'Transportable+Tablespaces';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.askthegerman.com/archives/210/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flashback Queries</title>
		<link>http://www.askthegerman.com/archives/203</link>
		<comments>http://www.askthegerman.com/archives/203#comments</comments>
		<pubDate>Tue, 09 Dec 2008 13:50:21 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[AS OF]]></category>
		<category><![CDATA[Flashback Option]]></category>
		<category><![CDATA[Flashback Query]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.askthegerman.com/?p=203</guid>
		<description><![CDATA[Working with the Oracle Flashback option we can restore the old data using flashback queries. Introduced in Oracle Version 9.2 the &#34;AS OF&#34; clause can be used to: find the old data restore the old data Mistakenly set the salary of Manager King to a wrong value: SQL&#62; update emp set sal=4500 where ename=&#8217;KING&#8217;; 1 [...]]]></description>
			<content:encoded><![CDATA[<p>Working with the Oracle Flashback option we can restore the old data using flashback queries. Introduced in Oracle Version 9.2 the &quot;AS OF&quot; clause can be used to:</p>
<ul>
<li>find the old data</li>
<li>restore the old data </li>
</ul>
<p>Mistakenly set the salary of Manager King to a wrong value: <br />      <em><br />      SQL&gt; update emp set sal=4500 where ename=&#8217;KING&#8217;;<br />      1 row updated.<br />      SQL&gt; commit;<br />      Commit complete.</em></p>
<p><em>SQL&gt; select ename, sal from emp where ename=&#8217;KING&#8217;;<br />     ENAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SAL<br />      &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br />      KING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4500</em></p>
<p>We can query the old value again using the &quot;AS OF&quot; clause and specifying a time interval:</p>
<p>Issuing this query will tell us the correct value as it was existing 15 minutes before.<em></em></p>
<p><em>SELECT ename, sal FROM emp<br />      AS OF TIMESTAMP (SYSTIMESTAMP &#8211; INTERVAL &#8217;15&#8242; MINUTE)<br />      WHERE ename = &#8216;KING&#8217;;</em></p>
<p><em>ENAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SAL<br />      &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br />      KING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5000</em></p>
<p>Now we can use flashback query as a sub query in an update statement to restore back to the old value. The command is as follows:</p>
<p><em>update emp<br />      set sal = (<br />      SELECT sal FROM emp<br />      AS OF TIMESTAMP (SYSTIMESTAMP &#8211; INTERVAL &#8217;15&#8242; MINUTE) where ename=&#8217;KING&#8217;)<br />      where ename=&#8217;KING&#8217;;</em></p>
<p>In case you are going to use this for testing purposes, you might find it usefully to record the referencing SCN and use flashback query in combination with the recorded SCN.</p>
<p><em>SQL&gt; select dbms_flashback.get_system_change_number from dual;<br />     GET_SYSTEM_CHANGE_NUMBER<br />      &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4312233</em></p>
<p>Now changing a value on purpose:</p>
<p><em>SQL&gt; update emp set sal=4300 where ename=&#8217;KING&#8217;;<br />     1 row updated.</em></p>
<p><em>SQL&gt; commit;<br />     Commit complete.</em></p>
<p><em>SQL&gt; select ename, sal from emp where ename=&#8217;KING&#8217;;<br />     ENAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SAL<br />      &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br />      KING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4300<br />      </em><br />      Then you might not know the previous salary of MILLER but you do know the SCN when it refered to the old value and the original value can be updated and restored with flashback query by using the SCN noted prior to the update statement.</p>
<p>Here is the required query:</p>
<p><em>SELECT ename, sal FROM emp<br />      AS OF SCN 4312233<br />      where ename=&#8217;KING&#8217;;</em></p>
<p><em>ENAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SAL<br />      &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br />      KING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4300</em></p>
<p>And you can restore the old value by updating the row or better you directly restore the old value using the following update with flashback sub query:</p>
<p><em>update emp<br />      set sal = (<br />      SELECT sal FROM emp<br />      AS OF SCN 4312233 where ename=&#8217;KING&#8217;)<br />      where ename=&#8217;KING&#8217;;</em> </p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.askthegerman.com%2Farchives%2F203';
  addthis_title  = 'Flashback+Queries';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.askthegerman.com/archives/203/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up BI Publisher against MySQL</title>
		<link>http://www.askthegerman.com/archives/197</link>
		<comments>http://www.askthegerman.com/archives/197#comments</comments>
		<pubDate>Sun, 07 Dec 2008 17:08:35 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Web Technologies]]></category>
		<category><![CDATA[Webserver]]></category>
		<category><![CDATA[Apache Tomcat]]></category>
		<category><![CDATA[BI Publisher]]></category>
		<category><![CDATA[Business Intelligence Suit]]></category>
		<category><![CDATA[Classpath]]></category>
		<category><![CDATA[Data Source]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WEBDAV]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xmlp-server-config.xml]]></category>
		<category><![CDATA[xmlpserver.war]]></category>
		<category><![CDATA[XMPL Server]]></category>

		<guid isPermaLink="false">http://www.askthegerman.com/?p=197</guid>
		<description><![CDATA[Oracle&#8217;s BI Publisher which is part of the Oracle Business Intelligence Suit has at least within Enterprise Computing environment established as a reliable and preferable choice when it comes to replace the somewhat aged Oracle Reports. Once being familiar with it you will ask yourself about why switching tool when it comes to the need [...]]]></description>
			<content:encoded><![CDATA[<p>Oracle&#8217;s BI Publisher which is part of the Oracle Business Intelligence Suit has at least within Enterprise Computing environment established as a reliable and preferable choice when it comes to replace the somewhat aged Oracle Reports.</p>
<p>Once being familiar with it you will ask yourself about why switching tool when it comes to the need of creating reports in a normal web design world mostly using MySQL Databases within a &quot;LAMP&quot; environment.</p>
<p>Written as an universal reporting tool BI Publishes does offer us a more or less universal data interface based on JDBC connections. And being able to act itself as a callable web service offering WEBDAV services based on XML data exchange it anyway seems to be an excellent choice for this world.</p>
<p>Already Oracle&#8217;s installation instructions does give you a quick idea about setting up BI Publisher working against some MySQL Database. But acting&nbsp; in a Web environment you might find it cool integration the BI Publisher within an already existing Apache Tomcat environment and for exactly this environment I will give you a short explanation about getting things together and ready for work.</p>
<p>First we will pick the BI Publisher software itself by copying the xmlpserver.war file from the distribution DVD and throwing it into the webapps folder of our Apache Tomcat. Waiting a few seconds until the self-deploying mechanism of the Apache Tomcat has extracted the files for us, we need to specify the access path to our project and development repository within the file xmlp-server-config.xml.</p>
<p>Having done that, we need to add the MySQL JDBC driver to our system and making it known within the environment of the Apache Tomcat. (The MySQL JDBC driver can be downloaded from: <a href="http://www.mysql.com/products/connector/j/">http://www.mysql.com/products/connector/j/</a>.) </p>
<p>So with the downloaded fileready, we have to extract it to any place we like onto our disk. Just I would recommend you to put it somewhere close to your MySQL installation for you being able to later on remember it again. Finally extracted and ready to use, we have to add the information about the mysql-connector-java- <version>-bin.jar file to the Java Classpath of the Apache Tomcat and finally restarting it:</version></p>
<p><img alt="Configuring Java Classpath" title="Configuring Java Classpath" src="http://www.askthegerman.com/wp-content/uploads/bip/bip01.jpg" height="290" width="300" />&nbsp;</p>
<p>Having this set, as a last step we have to invoke the BI Publisher itself, in which we then will configure the new JDBC data source within the Admin region of it: </p>
<p><img alt="Configuring JDBC Data Source" title="Configuring JDBC Data Source" src="http://www.askthegerman.com/wp-content/uploads/bip/bip02.jpg" height="155" width="400" />&nbsp;</p>
<p>And now with this tweaking ready, MySQL DB should connect, open and work for you like a charm. </p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.askthegerman.com%2Farchives%2F197';
  addthis_title  = 'Setting+up+BI+Publisher+against+MySQL';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.askthegerman.com/archives/197/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
