<?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>blog.watashii &#187; oracle</title>
	<atom:link href="http://blog.watashii.com/tag/oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.watashii.com</link>
	<description></description>
	<lastBuildDate>Wed, 02 Nov 2011 02:23:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Oracle SQLPlus Query Output to a File</title>
		<link>http://blog.watashii.com/2011/02/oracle-sqlplus-query-output-to-a-file/</link>
		<comments>http://blog.watashii.com/2011/02/oracle-sqlplus-query-output-to-a-file/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 03:48:04 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlplus]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=548</guid>
		<description><![CDATA[Here is a simple way to output SQL query output into a file, via command line based SQLPlus. Step 1: Nominate the output file location. In this case this is a Unix location. SQL&#62; spool /tmp/output.txt Step 2: Perform your SQL query. SQL&#62; select * from tab; Step 3: Close the file. SQL&#62; spool off [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/' rel='bookmark' title='Permanent Link: Starting / Shutdown Oracle Database in Unix'>Starting / Shutdown Oracle Database in Unix</a></li>
<li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/08/unix-file-size-listing-du-command/' rel='bookmark' title='Permanent Link: UNIX file size listing &#8211; du command'>UNIX file size listing &#8211; du command</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.watashii.com/wp-content/uploads/2010/11/oraclelogo.jpg"><img class="alignnone size-full wp-image-496" title="oraclelogo" src="http://blog.watashii.com/wp-content/uploads/2010/11/oraclelogo.jpg" alt="" width="220" height="100" /></a></p>
<p>Here is a simple way to output SQL query output into a file, via command line based SQLPlus.</p>
<h5><strong>Step 1:</strong> Nominate the output file location. In this case this is a Unix location.</h5>
<p><code>SQL&gt; spool /tmp/output.txt</code></p>
<h5><strong>Step 2:</strong> Perform your SQL query.</h5>
<p><code>SQL&gt; select * from tab;</code></p>
<h5><strong>Step 3:</strong> Close the file.</h5>
<p><code>SQL&gt; spool off</code></p>
<h5><strong>Tip:</strong> Use <strong><em>set lines</em></strong> statement to adjust output display</h5>
<p><span id="more-548"></span></p>
<p>The other method is doing this outside of SQLPlus in a single command.  Within the Unix shell, you can write your SQL query statements within an input sql file; eg <em>input.sql</em>, and redirect the output to <em>output.txt</em>.</p>
<p><code># sqlplus USER/PASS@DBSID &lt; /tmp/input.sql &gt; /tmp/output.txt</code></p>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/' rel='bookmark' title='Permanent Link: Starting / Shutdown Oracle Database in Unix'>Starting / Shutdown Oracle Database in Unix</a></li>
<li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/08/unix-file-size-listing-du-command/' rel='bookmark' title='Permanent Link: UNIX file size listing &#8211; du command'>UNIX file size listing &#8211; du command</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2011/02/oracle-sqlplus-query-output-to-a-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting / Shutdown Oracle Database in Unix</title>
		<link>http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/</link>
		<comments>http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 02:40:42 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[shutdown]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=497</guid>
		<description><![CDATA[This simple guide to shows how to start /stop your Oracle database from Unix.  You must have logon access to do this. Step 1 Unix login as oracle (usually the user that installed the database) Step 2 Make sure your environment variables are set, eg: ORACLE_SID=MYDBSID ORACLE_BASE=/opt/oracle ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1 LD_LIBRARY_PATH=/opt/oracle/product/11.2.0/dbhome_1/lib PATH=/usr/bin:/usr/sbin:/usr/ucb:/usr/local:/usr/local/bin:/usr/local/sbin:/opt/oracle/product/11.2.0/dbhome_1/bin Step 3 &#8211; Start DB [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2009/11/oracle-timezone-conversions-gmt-to-localtime/' rel='bookmark' title='Permanent Link: Oracle Timezone Conversions &#8211; GMT to localtime (and back)'>Oracle Timezone Conversions &#8211; GMT to localtime (and back)</a></li>
<li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2011/02/oracle-sqlplus-query-output-to-a-file/' rel='bookmark' title='Permanent Link: Oracle SQLPlus Query Output to a File'>Oracle SQLPlus Query Output to a File</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.watashii.com/wp-content/uploads/2010/11/oraclelogo.jpg"><img class="alignnone size-full wp-image-496" title="oraclelogo" src="http://blog.watashii.com/wp-content/uploads/2010/11/oraclelogo.jpg" alt="" width="220" height="100" /></a></p>
<p>This simple guide to shows how to start /stop your Oracle database from Unix.  You must have logon access to do this.</p>
<h3>Step 1</h3>
<p>Unix login as <strong><em>oracle </em></strong>(usually the user that installed the database)</p>
<h3>Step 2</h3>
<p>Make sure your environment variables are set, eg:</p>
<pre><code>ORACLE_SID=<em>MYDBSID</em>
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1
LD_LIBRARY_PATH=/opt/oracle/product/11.2.0/dbhome_1/lib
PATH=/usr/bin:/usr/sbin:/usr/ucb:/usr/local:/usr/local/bin:/usr/local/sbin:/opt/oracle/product/11.2.0/dbhome_1/bin</code></pre>
<h3>Step 3 &#8211; Start DB Instance</h3>
<p>On the Unix command line, run <strong><em>sqlplus </em></strong>with <strong><em>sysdba</em></strong>, and simply type <strong><em>startup </em></strong>in the prompt to start it up.</p>
<pre><code>oracle@db-srv-01 % sqlplus '/ as sysdba'

SQL*Plus: Release 11.2.0.1.0 Production on Tue Nov 30 12:06:47 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL&gt; startup
ORACLE instance started.

Total System Global Area 3207790592 bytes
Fixed Size                  2152368 bytes
Variable Size            2449475664 bytes
Database Buffers          738197504 bytes
Redo Buffers               17965056 bytes
Database mounted.
Database opened.</code></pre>
<h3>Step 4 &#8211; Start Listener</h3>
<p>To start the oracle listener (assuming listener.ora is setup), run <strong><em>lsnrctl start</em></strong></p>
<pre><code>oracle@db-srv-01 % lsnrctl start

LSNRCTL for Solaris: Version 11.2.0.1.0 - Production on 30-NOV-2010 12:00:34

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Starting /opt/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Solaris: Version 11.2.0.1.0 - Production
System parameter file is /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/db-srv-01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-srv-01)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db-srv-01)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Solaris: Version 11.2.0.1.0 - Production
Start Date                30-NOV-2010 12:00:35
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/db-srv-01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-srv-01)(PORT=1521)))
The listener supports no services
The command completed successfully</code></pre>
<h3>Step 4 &#8211; Shutdown</h3>
<p>Similarly, to shutdown the instance, type <strong><em>shudown normal</em></strong> within <strong><em>sqlplus</em></strong>.</p>
<p>Stop the listener, by running <strong><em>lsnrctl stop</em></strong></p>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2009/11/oracle-timezone-conversions-gmt-to-localtime/' rel='bookmark' title='Permanent Link: Oracle Timezone Conversions &#8211; GMT to localtime (and back)'>Oracle Timezone Conversions &#8211; GMT to localtime (and back)</a></li>
<li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2011/02/oracle-sqlplus-query-output-to-a-file/' rel='bookmark' title='Permanent Link: Oracle SQLPlus Query Output to a File'>Oracle SQLPlus Query Output to a File</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypt Passwords With Weblogic Server</title>
		<link>http://blog.watashii.com/2010/05/encrypt-passwords-with-weblogic-server/</link>
		<comments>http://blog.watashii.com/2010/05/encrypt-passwords-with-weblogic-server/#comments</comments>
		<pubDate>Tue, 04 May 2010 02:19:29 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[encrypt]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[weblogic]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=340</guid>
		<description><![CDATA[In a Weblogic Server environment, sometimes passwords must be unavoidably stored in text files, for example database connection details within JDBC configuration files.  When running Weblogic in production mode, only encrypted password is accepted to ensure that the password is never exposed as clear text.  To generate the encrypted password, the weblogic.security.Encrypt utility can be [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2010/06/start-stop-weblogic-without-username-password/' rel='bookmark' title='Permanent Link: Start &#038; Stop Weblogic Without Username &#038; Password'>Start &#038; Stop Weblogic Without Username &#038; Password</a></li>
<li><a href='http://blog.watashii.com/2010/06/weblogic-portal-authorization-get-and-check-users-roles/' rel='bookmark' title='Permanent Link: Weblogic Portal Authorization &#8211; Get and Check User&#8217;s Roles'>Weblogic Portal Authorization &#8211; Get and Check User&#8217;s Roles</a></li>
<li><a href='http://blog.watashii.com/2010/06/reading-portlet-preferences-in-weblogic-portal/' rel='bookmark' title='Permanent Link: Reading Portlet Preferences in Weblogic Portal'>Reading Portlet Preferences in Weblogic Portal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.watashii.com/wp-content/uploads/2010/05/weblogic_password.png"><img class="alignnone size-full wp-image-341" title="weblogic_password" src="http://blog.watashii.com/wp-content/uploads/2010/05/weblogic_password.png" alt="" width="373" height="259" /></a></p>
<p>In a Weblogic Server environment, sometimes passwords must be unavoidably stored in text files, for example database connection details within JDBC configuration files.  When running Weblogic in production mode, only encrypted password is accepted to ensure that the password is never exposed as clear text.  To generate the encrypted password, the <em>weblogic.security.Encrypt</em> utility can be used, which generates a hashed password with a &#8220;{3DES}&#8221; prepended.</p>
<p>In Unix environment:</p>
<p><code>$ cd /opt/bea/user_projects/domains/mydomain/bin<br />
$ . setDomainEnv.sh<br />
$ java weblogic.security.Encrypt <em>mycleartextpasswordhere</em><br />
{3DES}xLLwrOm7asb4imZOYYwxz5TcBqDBEe6S</code></p>
<p>In Windows environment:</p>
<p><code>C:\&gt;cd c:\bea\domains\mydomain\bin<br />
C:\bea\domains\mydomain\bin&gt;setDomainEnv.cmd<br />
C:\bea\domains\mydomain\bin&gt;java weblogic.security.Encrypt <em>mycleartextpasswordhere</em><br />
{3DES}lieJgIkTqg1xSBBoy3YxnHbPuz+tMxhY</code></p>
<p>Note that running the same command on different environment (or different Weblogic server installation) will produce a different password.</p>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2010/06/start-stop-weblogic-without-username-password/' rel='bookmark' title='Permanent Link: Start &#038; Stop Weblogic Without Username &#038; Password'>Start &#038; Stop Weblogic Without Username &#038; Password</a></li>
<li><a href='http://blog.watashii.com/2010/06/weblogic-portal-authorization-get-and-check-users-roles/' rel='bookmark' title='Permanent Link: Weblogic Portal Authorization &#8211; Get and Check User&#8217;s Roles'>Weblogic Portal Authorization &#8211; Get and Check User&#8217;s Roles</a></li>
<li><a href='http://blog.watashii.com/2010/06/reading-portlet-preferences-in-weblogic-portal/' rel='bookmark' title='Permanent Link: Reading Portlet Preferences in Weblogic Portal'>Reading Portlet Preferences in Weblogic Portal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2010/05/encrypt-passwords-with-weblogic-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle Timezone Conversions &#8211; GMT to localtime (and back)</title>
		<link>http://blog.watashii.com/2009/11/oracle-timezone-conversions-gmt-to-localtime/</link>
		<comments>http://blog.watashii.com/2009/11/oracle-timezone-conversions-gmt-to-localtime/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 14:32:24 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[gmt]]></category>
		<category><![CDATA[localtime]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[timezone]]></category>
		<category><![CDATA[utc]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=290</guid>
		<description><![CDATA[GMT to Local Time Convert a datetime value (which has no timezone info, but assumed as GMT/UTC) to a local datetime (based on timezone parameter as set by SESSIONTIMEZONE, eg &#8216;+11:00&#8242;): SELECT CAST((FROM_TZ(CAST(TO_DATE('1999-12-01 11:00:00', 'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), 'GMT') AT LOCAL) AS DATE) "Local Time" FROM DUAL; Local Time -------------------------------------------------- 1/12/1999 10:00:00 PM Explaining the [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/' rel='bookmark' title='Permanent Link: Starting / Shutdown Oracle Database in Unix'>Starting / Shutdown Oracle Database in Unix</a></li>
<li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/09/oracle-null-indexing/' rel='bookmark' title='Permanent Link: Oracle Index Null Values'>Oracle Index Null Values</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h3><img class="alignnone size-full wp-image-293" title="clock" src="http://blog.watashii.com/wp-content/uploads/2009/11/clock.jpg" alt="clock" width="435" height="435" /></h3>
<h3>GMT to Local Time</h3>
<p>Convert a datetime value (which has no timezone info, but assumed as GMT/UTC) to a local datetime (based on timezone parameter as set by <em>SESSIONTIMEZONE</em>, eg &#8216;+11:00&#8242;):</p>
<pre><code>SELECT CAST((FROM_TZ(CAST(TO_DATE('1999-12-01 11:00:00',
'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), 'GMT')
AT LOCAL) AS DATE) "Local Time"
FROM DUAL;

Local Time
--------------------------------------------------
1/12/1999 10:00:00 PM</code></pre>
<p><span id="more-290"></span></p>
<h3>Explaining the code:</h3>
<p>1) <strong><em>TO_DATE(&#8216;&#8230;&#8217;,  &#8216;YYYY-MM-DD HH24:MI:SS&#8217;)</em></strong> converts the string value (which we assume it is GMT) to a datetime datatype. Contains no timezone info.</p>
<p>2) <strong><em>CAST(&#8230; AS TIMESTAMP)</em></strong> converts the datetime value to a timestamp datatype. Contains no timezone info.</p>
<p>3) <em><strong>FROM_TZ(&#8230;, &#8216;GMT&#8217;)</strong> </em>adds the timezone value to the timestamp datatype.  In this case, the GMT timezone was added.  Alternatively use:  <strong><em>FROM_TZ(&#8230;, &#8216;+00:00&#8242;)</em></strong></p>
<p>4) <strong><em>&#8230; AT LOCAL</em></strong> performs the time shift of the timestamp value into Oracle DB&#8217;s local timestamp.  It is also updated with the new timezone info (based on the <em>SESSIONTIMEZONE </em>value, such as <em>+11:00</em>).  Alternatively use:  <strong><em>&#8230; AT TIME ZONE SESSIONTIMEZONE</em></strong> or  <strong><em>&#8230; AT TIME ZONE &#8216;+11:00&#8242;</em></strong></p>
<p>5) <strong><em>CAST(&#8230; AS DATE)</em></strong> converts the timestamp value back to a datetime datatype. Timezone info is discarded.</p>
<h3>Alternatives that does the same are:</h3>
<pre><code>SELECT CAST((FROM_TZ(CAST(TO_DATE('1999-12-01 11:00:00',
'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), <strong>'GMT'</strong>)
AT TIME ZONE <strong>SESSIONTIMEZONE</strong>) AS DATE)
FROM DUAL;

SELECT CAST((FROM_TZ(CAST(TO_DATE('1999-12-01 11:00:00',
'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), <strong>'+00:00'</strong>)
AT TIME ZONE <strong>'+11:00'</strong>) AS DATE)
FROM DUAL;

SELECT CAST((FROM_TZ(CAST(TO_DATE('1999-12-01 11:00:00',
'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), <strong>'GMT'</strong>)
AT TIME ZONE <strong>'Australia/Victoria'</strong>) AS DATE)
FROM DUAL;</code></pre>
<h3>Local Time to GMT</h3>
<p>To perform a reverse from a local time back to GMT time, we can simply reverse the timezone indicators in the same query:</p>
<pre><code>SELECT CAST((FROM_TZ(CAST(TO_DATE('1999-12-01 22:00:00',
'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), <strong>SESSIONTIMEZONE</strong>)
AT TIME ZONE <strong>'GMT'</strong>) AS DATE)
FROM DUAL;</code></pre>
<p><a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch4datetime.htm" target="_blank"><br />
More info&#8230;</a></p>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/' rel='bookmark' title='Permanent Link: Starting / Shutdown Oracle Database in Unix'>Starting / Shutdown Oracle Database in Unix</a></li>
<li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/09/oracle-null-indexing/' rel='bookmark' title='Permanent Link: Oracle Index Null Values'>Oracle Index Null Values</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2009/11/oracle-timezone-conversions-gmt-to-localtime/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BusinessObjects Universe Designer &#8211; Sysdate Value Object</title>
		<link>http://blog.watashii.com/2009/06/businessobjects-universe-designer-sysdate-value-object/</link>
		<comments>http://blog.watashii.com/2009/06/businessobjects-universe-designer-sysdate-value-object/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 03:00:49 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[BusinessObjects]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sysdate]]></category>
		<category><![CDATA[universe]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=195</guid>
		<description><![CDATA[Creating SYSDATE value objects in a Universe (via Oracle connection) can simply be done as shown above.   I have simply created a single-value dimension object, which can be used anywhere within a query (result/condition/sort).  Having sysdate values allows the flexibility to create dynamic time-based reports.  For example you can schedule a weekly report to extract [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/10/businessobjects-delete-universes-in-cmc/' rel='bookmark' title='Permanent Link: BusinessObjects &#8211; Delete Universes in CMC'>BusinessObjects &#8211; Delete Universes in CMC</a></li>
<li><a href='http://blog.watashii.com/2008/09/businessobjects-internal-error-when-connecting-windows-clients/' rel='bookmark' title='Permanent Link: BusinessObjects &#8211; Internal Error when connecting Windows clients'>BusinessObjects &#8211; Internal Error when connecting Windows clients</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-196" title="universe_sysdate" src="http://blog.watashii.com/wp-content/uploads/2009/06/universe_sysdate.png" alt="universe_sysdate" width="434" height="328" /></p>
<p>Creating SYSDATE value objects in a Universe (via Oracle connection) can simply be done as shown above.   I have simply created a single-value dimension object, which can be used anywhere within a query (result/condition/sort).  Having sysdate values allows the flexibility to create dynamic time-based reports.  For example you can schedule a weekly report to extract data from the past 7 days starting from the current time the report was run.</p>
<p>Note, when parsing the object against the database (Oracle), an error will appear. <em>ORA-00903: Invalid table name.</em></p>
<p>You can just ignore this error and press ok.</p>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/10/businessobjects-delete-universes-in-cmc/' rel='bookmark' title='Permanent Link: BusinessObjects &#8211; Delete Universes in CMC'>BusinessObjects &#8211; Delete Universes in CMC</a></li>
<li><a href='http://blog.watashii.com/2008/09/businessobjects-internal-error-when-connecting-windows-clients/' rel='bookmark' title='Permanent Link: BusinessObjects &#8211; Internal Error when connecting Windows clients'>BusinessObjects &#8211; Internal Error when connecting Windows clients</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2009/06/businessobjects-universe-designer-sysdate-value-object/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Oracle Index Null Values</title>
		<link>http://blog.watashii.com/2008/09/oracle-null-indexing/</link>
		<comments>http://blog.watashii.com/2008/09/oracle-null-indexing/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 12:02:39 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=66</guid>
		<description><![CDATA[When creating Oracle indexes, Oracle ignores the NULL values.  For example, the following index was created over &#8220;emp_name&#8221; column. create index emp_name_idx on employees (emp_name); Querying for a NULL value on the indexed column would yield a full table scan. select emp_name from employees where emp_name is NULL; So how can we make Oracle perform [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/07/plsql-pipelined-table-function/' rel='bookmark' title='Permanent Link: PL/SQL &#8211; Pipelined Table Function'>PL/SQL &#8211; Pipelined Table Function</a></li>
<li><a href='http://blog.watashii.com/2009/11/oracle-timezone-conversions-gmt-to-localtime/' rel='bookmark' title='Permanent Link: Oracle Timezone Conversions &#8211; GMT to localtime (and back)'>Oracle Timezone Conversions &#8211; GMT to localtime (and back)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>When creating Oracle indexes, Oracle ignores the NULL values.  For example, the following index was created over &#8220;emp_name&#8221; column.</p>
<pre name="code" class="sql">create index emp_name_idx
on employees (emp_name);</pre>
<p>Querying for a NULL value on the indexed column would yield a full table scan.</p>
<pre name="code" class="sql">select emp_name from employees where emp_name is NULL;</pre>
<p>So how can we make Oracle perform a fast indexed search?</p>
<p>The solution is to index NULL values with a function-based index.  The following example replaces all the NULL values with a string named &#8216;null&#8217; (note, this can be any arbitrary string).  This allows the NULL to be included as if it was a real value.</p>
<pre name="code" class="sql">create index emp_name_idx
on employees (nvl(emp_name,'null'));</pre>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/07/plsql-pipelined-table-function/' rel='bookmark' title='Permanent Link: PL/SQL &#8211; Pipelined Table Function'>PL/SQL &#8211; Pipelined Table Function</a></li>
<li><a href='http://blog.watashii.com/2009/11/oracle-timezone-conversions-gmt-to-localtime/' rel='bookmark' title='Permanent Link: Oracle Timezone Conversions &#8211; GMT to localtime (and back)'>Oracle Timezone Conversions &#8211; GMT to localtime (and back)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2008/09/oracle-null-indexing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle SQL Loader &#8211; Importing CSV files to a table</title>
		<link>http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/</link>
		<comments>http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 07:23:21 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[control file]]></category>
		<category><![CDATA[import csv]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql loader]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=46</guid>
		<description><![CDATA[This post shows how to easily insert data from a CSV file into a database table, using the Oracle SQL Loader tool. We will only concentrate on importing CSV formatted data to the Oracle table with a 1-to-1 column mapping, otherwise I will need to write a book. Users can easily reuse my code, and [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2008/09/oracle-null-indexing/' rel='bookmark' title='Permanent Link: Oracle Index Null Values'>Oracle Index Null Values</a></li>
<li><a href='http://blog.watashii.com/2008/07/plsql-pipelined-table-function/' rel='bookmark' title='Permanent Link: PL/SQL &#8211; Pipelined Table Function'>PL/SQL &#8211; Pipelined Table Function</a></li>
<li><a href='http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/' rel='bookmark' title='Permanent Link: Starting / Shutdown Oracle Database in Unix'>Starting / Shutdown Oracle Database in Unix</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table"><img class="alignnone size-full wp-image-49" title="sqlloader_ss" src="http://blog.watashii.com/wp-content/uploads/2008/08/sqlloader.png" alt="" width="575" height="324" /></a></p>
<p>This post shows how to easily insert data from a CSV file into a database table, using the Oracle SQL Loader tool.   We will only concentrate on importing <a href="http://en.wikipedia.org/wiki/Comma-separated_values" target="_blank">CSV</a> formatted data to the Oracle table with a 1-to-1 column mapping, otherwise I will need to write a book.   Users can easily reuse my code, and just customise the columns to their needs.<br />
<span id="more-46"></span><br />
Source files: <a href="http://blog.watashii.com/wp-content/uploads/2008/08/import.ctl">import.ctl</a> <a href="http://blog.watashii.com/wp-content/uploads/2008/08/import.csv">import.csv</a></p>
<h3>Step 1</h3>
<p>Using the command line/prompt, use SQL Plus to login to your Oracle database.   Make sure the user has permission to create tables.</p>
<p><code>$ sqlplus user/password@DBINSTANCE;</code></p>
<h3>Step 2</h3>
<p>Under this user, create a table where you want to import the data  (skip this step if the table already exists).</p>
<pre name="code" class="sql">SQL&gt; create table T_IMPORTED_DATA
2  (
3    SERIAL       NUMBER(16),
4    TITLE        VARCHAR2(64),
5    PUBLISH_DATE DATE,
6    DESCRIPTION  VARCHAR2(64)
7  )
8  /
Table created</pre>
<h3>Step 3</h3>
<p>We use an Oracle utility called SQL Loader.   The utility is a command line based, and should work if SQL Plus works (as above).   It accepts the 2 source files: the data CSV file, and the CTL control file which specifies how to process our data file.  The only thing you need to do is customize the last few rows of the control file to specify how to process each column on the CSV.  Each row has the following format:</p>
<p><code>&lt;column_name&gt;  &lt;data_type&gt;  &lt;NULLIF column_name = BLANKS&gt;</code></p>
<p><em>&lt;column_name&gt;</em> specifies the table column to put the data<br />
<em> &lt;data_type&gt;</em> specifies data type conversion when parsing the CSV data<br />
<em> &lt;NULLIF column_name = BLANKS&gt;</em> is always added to handle empty CSV data, NULL will be inserted</p>
<p>Note that each successive row in CTL file represents each column to be parsed on the CSV, in order.</p>
<h3>Step 4</h3>
<p>To begin the import, put all the files into one directory, and run the sqlldr command, under the user which owns the table created above.</p>
<p><code>$ sqlldr userid=user/password@DB_INSTANCE_NAME control=import.ctl log=import.log data=import.csv</code></p>
<h3>Verify</h3>
<p>Log files will be created, import.log and import.bad.   Verify these to make sure any rows were skipped.  Otherwise the data should be added into the database table.</p>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2008/09/oracle-null-indexing/' rel='bookmark' title='Permanent Link: Oracle Index Null Values'>Oracle Index Null Values</a></li>
<li><a href='http://blog.watashii.com/2008/07/plsql-pipelined-table-function/' rel='bookmark' title='Permanent Link: PL/SQL &#8211; Pipelined Table Function'>PL/SQL &#8211; Pipelined Table Function</a></li>
<li><a href='http://blog.watashii.com/2010/11/starting-shutdown-oracle-database-in-unix/' rel='bookmark' title='Permanent Link: Starting / Shutdown Oracle Database in Unix'>Starting / Shutdown Oracle Database in Unix</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PL/SQL &#8211; Pipelined Table Function</title>
		<link>http://blog.watashii.com/2008/07/plsql-pipelined-table-function/</link>
		<comments>http://blog.watashii.com/2008/07/plsql-pipelined-table-function/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 13:16:33 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[pipelined]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=22</guid>
		<description><![CDATA[Normally when writing PL/SQL functions, they return a single value result.  But what if you want to return a collection type instead?  The easiest way to do this is via a pipelined function, with the PIPELINED keyword, in which rows are returned by the function iteratively.   It can be created at the schema level, or [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/09/oracle-null-indexing/' rel='bookmark' title='Permanent Link: Oracle Index Null Values'>Oracle Index Null Values</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Normally when writing PL/SQL functions, they return a single value result.  But what if you want to return a collection type instead?  The easiest way to do this is via a pipelined function, with the PIPELINED keyword, in which rows are returned by the function iteratively.   It can be created at the schema level, or inside a package.  I prefer the latter since its more portable, and easier to manage.</p>
<p>Inside the function, you return individual elements of the collection type, instead of returning the entire collection type when function ends.  This also has performance benefits, depending on your application.</p>
<p><span id="more-22"></span></p>
<p>The code below defines a custom number collection type and a pipelined function; within a package / package body.</p>
<pre name="code" class="sql">
CREATE PACKAGE mypackage AS
  TYPE num_type IS TABLE OF NUMBER;
  FUNCTION myfunction (x NUMBER) RETURN num_type PIPELINED;
END mypackage;
/

CREATE PACKAGE BODY mypackage AS
  -- myfunction returns a collection of elements (1,2,3,... x)
  FUNCTION myfunction (x NUMBER) RETURN num_type PIPELINED IS
    BEGIN
      FOR i IN 1..x LOOP
        -- each number is returned per iteration
        PIPE ROW(i);
      END LOOP;
      RETURN;
    END;
END mypackage;
/
</pre>
<p>To call the function, simply call:</p>
<pre name="code" class="sql">
SELECT * FROM TABLE(mypackage.myfunction(5));
</pre>
<p>Which results in:<br />
<code><br />
COLUMN_VALUE<br />
------------<br />
           1<br />
           2<br />
           3<br />
           4<br />
           5<br />
</code></p>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2008/08/oracle-sql-loader-importing-csv-files-into-a-table/' rel='bookmark' title='Permanent Link: Oracle SQL Loader &#8211; Importing CSV files to a table'>Oracle SQL Loader &#8211; Importing CSV files to a table</a></li>
<li><a href='http://blog.watashii.com/2008/09/oracle-null-indexing/' rel='bookmark' title='Permanent Link: Oracle Index Null Values'>Oracle Index Null Values</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2008/07/plsql-pipelined-table-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

