<?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>kwatog &#38; co.&#187; Oracle SQL</title>
	<atom:link href="http://kwatog.com/tag/oracle-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://kwatog.com</link>
	<description>tech notes and general nonsense</description>
	<lastBuildDate>Tue, 31 Jan 2012 06:27:55 +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>Oracle Power Function</title>
		<link>http://kwatog.com/blog/oracle/oracle-power-function/</link>
		<comments>http://kwatog.com/blog/oracle/oracle-power-function/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 03:30:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[Oracle SQL]]></category>
		<category><![CDATA[power function]]></category>
		<guid isPermaLink="false">http://kwatog.com/?p=681</guid>
		<description><![CDATA[There are some pl/sql functions that you rarely use and we always forget the syntax.And here&#8217;s another example &#8212; the power function. You know, that&#8217;s the n to the power of x (n^x). Again, I feel a bit ashamed for forgetting this one. Here&#8217;s the syntax. power(m,n); whereby m is the base. n is the [...]]]></description>
			<content:encoded><![CDATA[<p>There are some pl/sql functions that you rarely use and we always forget the syntax.And here&#8217;s another example &#8212; the power function.  You know, that&#8217;s the n to the power of x (n^x). Again, I feel a bit ashamed for forgetting this one. Here&#8217;s the syntax.<br />
<span id="more-681"></span><br />
<code><br />
power(m,n);<br />
</code></p>
<p>whereby<br />
m is the base.<br />
n is the exponent.</p>
<p>Example<br />
<code><br />
power(36,5);<br />
</code><br />
will return 1679616</p>
<p>Take note that this function returns NUMBER as the data type. That means the maximum value can only be 1.0 x 10^126. Later versions (10g onwards) can use binary_double as the base which makes the function output binary_double. I don&#8217;t know where you would need that large number, though. Also, if m is negative, then n must be an integer.</p>
<p>In case you are asking where I need it, there&#8217;s this code conversion whereby I needed to use the power function to get the value of a particular character. The exponent(n) is not fixed so I needed this function. To be specific, the function involves the pl/sql version of RowIdToRowIdNum of Siebel. I&#8217;ll post the code later.</p>
<p>References:</p>
<p>http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1594387900346571874</p>
<h4>Incoming search terms:</h4><ul><li>oracle power</li><li>oracle power function</li><li>oracle power function negative</li><li>oracle power functions</li><li>oracle sql display power</li><li>power function in sql oracle</li><li>power function pl/sql integers</li><li>power oracle binary_double ask tom</li><li>powerc oracle</li></ul>]]></content:encoded>
			<wfw:commentRss>http://kwatog.com/blog/oracle/oracle-power-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select Random Records in Oracle</title>
		<link>http://kwatog.com/blog/oracle/select-random-records-in-oracle/</link>
		<comments>http://kwatog.com/blog/oracle/select-random-records-in-oracle/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 06:32:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle SQL]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Random Query]]></category>
		<guid isPermaLink="false">http://kwatog.com/?p=47</guid>
		<description><![CDATA[Recently, I needed to sort the result of a query in random and show a limited number of records. Honestly, I didn&#8217;t know how to do it and had to search various online forums to get the correct answer. So for my own sanity, I&#8217;ll be posting the solution here. Step 1 SELECT field_name1, field_name2 [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I needed to sort the result of a query in random and show a limited number of records. Honestly, I didn&#8217;t know how to do it and had to search various online forums to get the correct answer. So for my own sanity, I&#8217;ll be posting the solution here.</p>
<p><strong>Step 1</strong><br />
<code>SELECT field_name1, field_name2<br />
FROM   table_name<br />
WHERE  field_query1 = 'ARGUMENT VAL'<br />
ORDER  BY dbms_random.VALUE;</code></p>
<p>The key here is the function dmbs_random.VALUE that generates, you guess it, random number. Its value is then used for ordering. The second step is to limit the output by using ROWNUM as below.</p>
<p><strong>Step 2</strong><br />
<code>SELECT field_name1, field_name2<br />
FROM  (SELECT field_name1, field_name2<br />
FROM   table_name<br />
WHERE  field_query1 = 'ARGUMENT VAL'<br />
ORDER  BY dbms_random.VALUE)<br />
WHERE ROWNUM &lt; 11;</code></p>
<p>If you&#8217;ll notice, I used a subquery here. Why didn&#8217;t I just include the rownum inside the subquery? It is because I wanted the subquery to finish the random ordering first before limiting the output to 10.</p>
<p><strong>Real World Example</strong><br />
<code><br />
SELECT order_num, pr_postn_id<br />
FROM (SELECT order_num, pr_postn_id<br />
      FROM siebel.s_order<br />
      WHERE order_num LIKE 'V-%'<br />
      ORDER BY dbms_random.VALUE)<br />
WHERE ROWNUM < 11;<br />
</code></p>
<p>I'll also need this similar solution for MySQL and will be discussed in my next post.</p>
<h4>Incoming search terms:</h4><ul><li>oracle select random records</li><li>oracle random sort</li><li>oracle random row</li><li>oracle select random rows</li><li>how to select random row in oracle</li><li>oracle randomize records</li><li>random select oracle</li><li>oracle select random record</li><li>select random oracle</li><li>random records oracle</li></ul>]]></content:encoded>
			<wfw:commentRss>http://kwatog.com/blog/oracle/select-random-records-in-oracle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!--
Hyper cache file: 94303759fb03e93ed1d5b7cce441bcd3
Cache created: 05-02-2012 02:48:47
HCE Version: 0.9.8
Load AVG: 0.04(5)
-->
