<?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>Database.fi &#187; Oracle 11g New Features</title>
	<atom:link href="http://www.database.fi/tag/oracle-11g-new-features/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.database.fi</link>
	<description>Database Performance &#38; Disaster Solutions</description>
	<lastBuildDate>Tue, 25 Oct 2011 07:43:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Oracle 11g virtual columns</title>
		<link>http://www.database.fi/2010/04/oracle-11g-virtual-columns/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=oracle-11g-virtual-columns</link>
		<comments>http://www.database.fi/2010/04/oracle-11g-virtual-columns/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 13:06:22 +0000</pubDate>
		<dc:creator>pparkko</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle 11g]]></category>
		<category><![CDATA[Oracle 11g New Features]]></category>

		<guid isPermaLink="false">http://www.database.fi/?p=74</guid>
		<description><![CDATA[When I found out about virtual columns I just had to try it.
Just a simple example for our familiar employees table. 
First I made a copy of the employees:
Create table duunarit as select * from employees;

SQL> desc duunarit
 Name                 [...]]]></description>
			<content:encoded><![CDATA[<p>When I found out about virtual columns I just had to try it.<br />
Just a simple example for our familiar employees table. </p>
<p>First I made a copy of the employees:<br />
Create table duunarit as select * from employees;</p>
<p><code><br />
SQL> desc duunarit<br />
 Name                                      Null?    Type<br />
 ----------------------------------------- -------- ---------------------</p>
<p> EMPLOYEE_ID                                        NUMBER(6)<br />
 FIRST_NAME                                         VARCHAR2(20)<br />
 LAST_NAME                                 NOT NULL VARCHAR2(25)<br />
 EMAIL                                     NOT NULL VARCHAR2(25)<br />
 PHONE_NUMBER                                       VARCHAR2(20)<br />
 HIRE_DATE                                 NOT NULL DATE<br />
 JOB_ID                                    NOT NULL VARCHAR2(10)<br />
 SALARY                                             NUMBER(8,2)<br />
 COMMISSION_PCT                                     NUMBER(2,2)<br />
 MANAGER_ID                                         NUMBER(6)<br />
 DEPARTMENT_ID                                      NUMBER(4)<br />
</code></p>
<p>I would like to add a salgrade column to the table with some simple reasoning based on salary:<br />
 when salary is less than 3000, print &#8216;Poor you&#8217;<br />
 when salary is 3000 &#8211; 5000, print &#8216;Lucky you&#8217;<br />
 when it is above 5000, print &#8216;You bastard&#8217;</p>
<p> <img src='http://www.database.fi/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So here is my column definition:</p>
<p><code>alter table duunarit add<br />
(salgrade varchar2(20)<br />
generated always as<br />
(<br />
case<br />
 when salary < 3000 then 'Poor you'<br />
 when salary < 5000 then 'Lucky you'<br />
 else 'You bastard'<br />
end<br />
)virtual<br />
);</p>
<p>Table altered.<br />
</code></p>
<p>Let's try it!</p>
<p><code>SQL> l<br />
  1* select last_name, salary, salgrade from duunarit</p>
<p>LAST_NAME                     SALARY SALGRADE<br />
------------------------- ---------- --------------------<br />
King                           24000 You bastard<br />
Kochhar                        17000 You bastard<br />
De Haan                        17000 You bastard<br />
Hunold                          9000 You bastard<br />
Ernst                           6000 You bastard<br />
Austin                          4800 Lucky you<br />
Pataballa                       4800 Lucky you<br />
Lorentz                         4200 Lucky you<br />
Greenberg                      12000 You bastard<br />
Faviet                          9000 You bastard<br />
Chen                            8200 You bastard</p>
<p>LAST_NAME                     SALARY SALGRADE<br />
------------------------- ---------- --------------------<br />
Sciarra                         7700 You bastard<br />
Urman                           7800 You bastard<br />
Popp                            6900 You bastard<br />
Raphaely                       11000 You bastard<br />
Khoo                            3100 Lucky you<br />
Baida                           2900 Poor you<br />
Tobias                          2800 Poor you<br />
Himuro                          2600 Poor you<br />
Colmenares                      2500 Poor you<br />
Weiss                           8000 You bastard<br />
Fripp                           8200 You bastard<br />
</code></p>
<p>This looks great functionality!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.database.fi/2010/04/oracle-11g-virtual-columns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

