<?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> &#187; Oracle</title>
	<atom:link href="http://freddysmind.com/blog/category/computers/databases/oracle-databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://freddysmind.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 14 Jul 2010 13:10:14 +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>Dealing with dates in Oracle &amp; Microsoft&#160;SQL</title>
		<link>http://freddysmind.com/blog/2010/04/dealing-with-dates-in-oracle-microsoft-sql/</link>
		<comments>http://freddysmind.com/blog/2010/04/dealing-with-dates-in-oracle-microsoft-sql/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 20:19:47 +0000</pubDate>
		<dc:creator>Freddy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://freddysmind.com/blog/?p=519</guid>
		<description><![CDATA[I&#8217;m not going to say much, the quoted comment from below explains it. Oracle pampers us. From http://www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-a-Date-Time-Stamp-in-SQL-Server.htm &#8220;I know I&#8217;m late to the party, but having dealt with both SQL Server and Oracle at length, it&#8217;s easy to say that date handling and manipulation in SQL Server leaves much to be desired. As evidenced [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not going to say much, the quoted comment from below explains it. Oracle pampers us.</p>
<p>From <a href="http://www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-a-Date-Time-Stamp-in-SQL-Server.htm">http://www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-a-Date-Time-Stamp-in-SQL-Server.htm</a></p>
<p>&#8220;I know I&#8217;m late to the party, but having dealt with both SQL Server and Oracle at length, it&#8217;s easy to say that date handling and manipulation in SQL Server leaves much to be desired. As evidenced by this thread, truncating dates in SQL Server oftentimes involves massive amounts of function nesting and string concatenation. Oracle offers a function named &#8220;trunc&#8221;, which does the same thing in a neat little package. The group I work for oftentimes deals with massive amounts of data, so we are all the time summarizing that data by day/month/quarter or even year in some cases. Remembering all the hoops to go through is just a mess, so I wrote a SQL Server equivalent to Oracle&#8217;s TRUNC function.</p>
<p>The function works like this:</p>
<p>fn_trunc(<em>p_date</em>,<em>period</em>)</p>
<p>For instance, if I want to truncate getdate() to today&#8217;s date:<br />
select fn_trunc(getdate(),&#8217;d')</p>
<p>or the first day of this month:</p>
<p>select fn_trunc(getdate(),&#8217;m')</p>
<p>.. and so on. fn_trunc will truncate any date to the nearest minute, hour, day, month, quarter or year. The period argument accepts the same arguments the SQL Server DATEPART function uses, as well as the equivalent arguments used in the Oracle TRUNC function.</p>
<p>I&#8217;ll paste the code below, and please note that this implementation is for a system-wide function. Also note that I have not exhaustively tested the performance of this function call, so please anyone chime in if you have discovered a quicker way to skin this cat. I stayed away from string concatenation where possible, but prefer that over things like multiple DATEPART calls.</p>
<p>&lt;code&gt;<br />
USE master<br />
SET QUOTED_IDENTIFIER ON<br />
SET ANSI_NULLS ON</p>
<p>EXEC sp_configure &#8216;allow updates&#8217;, 1<br />
RECONFIGURE WITH OVERRIDE<br />
GO</p>
<p>IF EXISTS (SELECT *<br />
FROM dbo.sysobjects<br />
WHERE uid = USER_ID(&#8216;system_function_schema&#8217;)<br />
AND name = &#8216;fn_trunc&#8217;)<br />
DROP FUNCTION system_function_schema.fn_trunc<br />
GO</p>
<p>/* ALL SYSTEM-WIDE FUNCTIONS MUST BEGIN WITH &#8220;fn_&#8221;"AND<br />
MUST BE ALL lowercase<br />
*/<br />
CREATE FUNCTION system_function_schema.fn_trunc<br />
(<br />
@p_date datetime,<br />
@p_period varchar(4) = &#8216;d&#8217;<br />
)<br />
returns smalldatetime<br />
as<br />
begin<br />
declare @l_date smalldatetime</p>
<p>set @l_date =<br />
case<br />
when @p_period in (&#8216;n&#8217;,'mi&#8217;)<br />
then cast(convert(varchar(16),@p_date,120) as smalldatetime)<br />
when @p_period in (&#8216;h&#8217;,'hh&#8217;)<br />
then cast(convert(varchar(14),@p_date,120)+&#8217;00&#8242; as smalldatetime)<br />
when @p_period in (&#8216;d&#8217;,'dd&#8217;)<br />
then cast(cast(@p_date as varchar(11)) as smalldatetime)<br />
when @p_period in (&#8216;w&#8217;,'wk&#8217;,'ww&#8217;)<br />
then dateadd(dd, 1 &#8211; datepart(dw, convert(varchar(10), @p_date, 111)),convert(varchar(10), @p_date, 111))<br />
when @p_period in (&#8216;m&#8217;,'mm&#8217;)<br />
then cast(convert(char(6),@p_date,112)+&#8217;01&#8242; as smalldatetime)<br />
when @p_period in (&#8216;q&#8217;,'qq&#8217;)<br />
then cast(cast(year(@p_date) as varchar(4)) + &#8216;/&#8217; + cast(datepart(q, @p_date) * 3 &#8211; 2 as varchar(2)) + &#8216;/01&#8242; as smalldatetime)<br />
when @p_period in (&#8216;y&#8217;,'yy&#8217;,'yyyy&#8217;)<br />
then cast(convert(char(4),@p_date,120)+&#8217;-01-01&#8242; as smalldatetime)<br />
else<br />
cast(cast(@p_date as varchar(11)) as smalldatetime)<br />
end</p>
<p>return @l_date<br />
end<br />
go</p>
<p>EXEC sp_configure &#8216;allow updates&#8217;, 0<br />
RECONFIGURE WITH OVERRIDE<br />
GO<br />
&lt;/code&gt;</p>
<p>&#8220;</p>
]]></content:encoded>
			<wfw:commentRss>http://freddysmind.com/blog/2010/04/dealing-with-dates-in-oracle-microsoft-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spool file&#160;header</title>
		<link>http://freddysmind.com/blog/2010/02/spool-file-header/</link>
		<comments>http://freddysmind.com/blog/2010/02/spool-file-header/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 14:48:48 +0000</pubDate>
		<dc:creator>Freddy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://freddysmind.com/blog/?p=512</guid>
		<description><![CDATA[set verify off feedback off pagesize 0 heading off linesize 4000 trimspool on trimout on wrap on serveroutput off arraysize 1 set verify off feedback off pagesize 0 heading off linesize 4000 trimspool on trimout on wrap on serveroutput off arraysize 1]]></description>
			<content:encoded><![CDATA[<p>set verify off feedback off pagesize 0 heading off linesize 4000 trimspool on trimout on wrap on serveroutput off arraysize 1</p>
<p>set</p>
<p>verify off</p>
<p>feedback off</p>
<p>pagesize 0</p>
<p>heading off</p>
<p>linesize 4000</p>
<p>trimspool on</p>
<p>trimout on</p>
<p>wrap on</p>
<p>serveroutput off</p>
<p>arraysize 1</p>
]]></content:encoded>
			<wfw:commentRss>http://freddysmind.com/blog/2010/02/spool-file-header/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Automated&#160;Start</title>
		<link>http://freddysmind.com/blog/2010/02/oracle-automated-start/</link>
		<comments>http://freddysmind.com/blog/2010/02/oracle-automated-start/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 23:03:31 +0000</pubDate>
		<dc:creator>Freddy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://freddysmind.com/blog/?p=506</guid>
		<description><![CDATA[From http://download.oracle.com/docs/cd/B19306_01/server.102/b15658/strt_stp.htm#CFAHAHGA 2.2.2 Automating Database Startup and Shutdown on Other Operating Systems To automate database startup and shutdown by using the dbstart and dbshut scripts: Log in as the root user. Edit the oratab file for your platform. To open the file, use one of the following commands: On Solaris: # vi /var/opt/oracle/oratab On AIX, [...]]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b15658/strt_stp.htm#CFAHAHGA">http://download.oracle.com/docs/cd/B19306_01/server.102/b15658/strt_stp.htm#CFAHAHGA</a><br />
2.2.2 Automating Database Startup and Shutdown on Other Operating Systems</p>
<p>To automate database startup and shutdown by using the dbstart and dbshut scripts:</p>
<p>Log in as the root user.</p>
<p>Edit the oratab file for your platform.</p>
<p>To open the file, use one of the following commands:</p>
<p>On Solaris:</p>
<p># vi /var/opt/oracle/oratab<br />
On AIX, HP-UX, Linux, and Tru64 UNIX:</p>
<p># vi /etc/oratab<br />
Database entries in the oratab file are displayed in the following format:</p>
<p>SID:ORACLE_HOME:{Y|N|W}<br />
In this example, the values Y and N specify whether you want the scripts to start up or shut down the database, respectively. For each database for which you want to automate shutdown and startup, first determine the instance identifier (SID) for that database, which is identified by the SID in the first field. Then, change the last field for each to Y.</p>
<p>You can set dbstart to autostart a single-instance database that uses an Automatic Storage Management installation that is auto-started by Oracle Clusterware. This is the default behavior for an Automatic Storage Management cluster. If you want to do this, then you must change the oratab entry of the database and the Automatic Storage Management installation to use a third field with the value W and N, respectively. These values specify that dbstart auto-starts the database only after the Automatic Storage Management instance is started.</p>
<p>Note:<br />
If you add new database instances to the system and if you want to automate startup for them, then you must edit the entries for those instances in the oratab file.</p>
]]></content:encoded>
			<wfw:commentRss>http://freddysmind.com/blog/2010/02/oracle-automated-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Oracle Express on 64 bit&#160;Ubuntu</title>
		<link>http://freddysmind.com/blog/2010/01/installing-oracle-express-on-64-bit-ubuntu/</link>
		<comments>http://freddysmind.com/blog/2010/01/installing-oracle-express-on-64-bit-ubuntu/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 16:31:11 +0000</pubDate>
		<dc:creator>Freddy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://freddysmind.com/blog/?p=488</guid>
		<description><![CDATA[http://littlebrain.org/2008/05/12/how-to-install-oracle-xe-in-ubuntu-64-bit/ http://forums.oracle.com/forums/thread.jspa?threadID=848385&#38;tstart=45 This is nothing to worry about &#8211; update-rc.d: warning: /etc/init.d/oracle-xe missing LSB style header After it&#8217;s been installed, configure it: sudo /etc/init.d/oracle-xe configure Configure stuff, I used all defaults I believe. Next in order to run sqlplus to do anything you need to source the config file: source /usr/lib/oracle/xe/app/oracle/product/10.2.0/client/bin/oracle_env.sh Which in turn gave [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://littlebrain.org/2008/05/12/how-to-install-oracle-xe-in-ubuntu-64-bit/">http://littlebrain.org/2008/05/12/how-to-install-oracle-xe-in-ubuntu-64-bit/</a></p>
<p><a href="http://forums.oracle.com/forums/thread.jspa?threadID=848385&amp;tstart=45">http://forums.oracle.com/forums/thread.jspa?threadID=848385&amp;tstart=45</a></p>
<p>This is nothing to worry about &#8211; update-rc.d: warning: /etc/init.d/oracle-xe missing LSB style header</p>
<p>After it&#8217;s been installed, configure it:</p>
<p>sudo /etc/init.d/oracle-xe configure</p>
<p>Configure stuff, I used all defaults I believe.</p>
<p>Next in order to run sqlplus to do anything you need to source the config file:</p>
<p>source /usr/lib/oracle/xe/app/oracle/product/10.2.0/client/bin/oracle_env.sh</p>
<p>Which in turn gave me this error:</p>
<p>/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh: 114: [[: not found</p>
<p>Which is entirely related to what shell that it is trying to run on. In the file definition you&#8217;ll find #! /bin/sh and if you change this to #! /bin/bash it will run properly. Fixed!</p>
<p>Now doing a &#8211; &#8216;which sqlplus&#8217; should return a path to sqlplus like this:</p>
<p>/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/sqlplus</p>
<p>SQLPLUS /NOLOG</p>
<p>CONNECT username/password</p>
<p>All of this so I can &#8216;Enable Remote HTTP Connection with SQL Command Line&#8217;</p>
<p>EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);</p>
<p>Now I have to reconfigure port forwarding on my router at home in order to remotely access the Oracle Admin Website and router.</p>
<p>To access the Oracle Admin Site remote I should be able to go to:</p>
<p>http://host:port/apex</p>
<p>Where host = my domain name or IP and port = the default 8080 port I setup</p>
<p>I need to port forward 8080 requests to the server but I can&#8217;t remotely change my router yet.</p>
<p>I currently have it forwarding port 80 to the server but in order to change the router remotely I&#8217;m supposed to access myip:80</p>
<p>So one of those two needs to change.</p>
<p>Change HTTP or FTP port via SQLPLUS</p>
<p>SQL&gt; begin</p>
<p>2    dbms_xdb.sethttpport(&#8217;80&#8242;);</p>
<p>3    dbms_xdb.setftpport(&#8217;2100&#8242;);</p>
<p>4  end;</p>
<p>5  /</p>
<p>CONNECT username/password<br />
All of this so I can &#8216;Enable Remote HTTP Connection with SQL Command Line&#8217; EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);Now I have to reconfigure port forwarding on my router at home in order to remotely access the Oracle Admin Website and router.To access the Oracle Admin Site remote I should be able to go to:http://host:port/apexWhere host = my domain name or IP and port = the default 8080 port I setupI need to port forward 8080 requests to the server but I can&#8217;t remotely change my router yet.I currently have it forwarding port 80 to the server but in order to change the router remotely I&#8217;m supposed to access myip:80So one of those two needs to change.<br />
Change HTTP or FTP port via SQLPLUS<br />
SQL&gt; begin 2    dbms_xdb.sethttpport(&#8217;80&#8242;); 3    dbms_xdb.setftpport(&#8217;2100&#8242;); 4  end; 5  /</p>
<p>So one of those two needs to change.</p>
<p>Change HTTP or FTP port via SQLPLUS</p>
<p>SQL&gt; begin</p>
<p>2    dbms_xdb.sethttpport(&#8217;80&#8242;);</p>
<p>3    dbms_xdb.setftpport(&#8217;2100&#8242;);</p>
<p>4  end;</p>
<p>5  /</p>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://freddysmind.com/blog/2010/01/installing-oracle-express-on-64-bit-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sql Plus&#160;command</title>
		<link>http://freddysmind.com/blog/2010/01/sql-plus-command/</link>
		<comments>http://freddysmind.com/blog/2010/01/sql-plus-command/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 19:57:43 +0000</pubDate>
		<dc:creator>Freddy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://freddysmind.com/blog/?p=486</guid>
		<description><![CDATA[sqlplus -S username/pw@sid @sqlfile.sql outputfile.txt args]]></description>
			<content:encoded><![CDATA[<p>sqlplus -S username/pw@sid @sqlfile.sql outputfile.txt args</p>
]]></content:encoded>
			<wfw:commentRss>http://freddysmind.com/blog/2010/01/sql-plus-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Dual&#160;Table</title>
		<link>http://freddysmind.com/blog/2009/12/oracle-dual-table/</link>
		<comments>http://freddysmind.com/blog/2009/12/oracle-dual-table/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 20:30:36 +0000</pubDate>
		<dc:creator>Freddy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://freddysmind.com/blog/?p=443</guid>
		<description><![CDATA[http://en.wikipedia.org/wiki/DUAL_table http://www.oracle.com/technology/pub/articles/10gdba/week7_10gdba.html]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/DUAL_table">http://en.wikipedia.org/wiki/DUAL_table</a></p>
<p><a href="http://www.oracle.com/technology/pub/articles/10gdba/week7_10gdba.html">http://www.oracle.com/technology/pub/articles/10gdba/week7_10gdba.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://freddysmind.com/blog/2009/12/oracle-dual-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle SQL&#160;result</title>
		<link>http://freddysmind.com/blog/2009/10/oracle-sql-result/</link>
		<comments>http://freddysmind.com/blog/2009/10/oracle-sql-result/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 18:19:17 +0000</pubDate>
		<dc:creator>Freddy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://freddysmind.com/blog/?p=407</guid>
		<description><![CDATA[Very good example(s) for connecting to an Oracle DB, submitting a statement, and printing the results. http://www.java2s.com/Code/Java/Database-SQL-JDBC/DemoResultSetOracle.htm Don&#8217;t know what this next one is but it looks important http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/refcur/index.html]]></description>
			<content:encoded><![CDATA[<p>Very good example(s) for connecting to an Oracle DB, submitting a statement, and printing the results.</p>
<p><a href="http://www.java2s.com/Code/Java/Database-SQL-JDBC/DemoResultSetOracle.htm">http://www.java2s.com/Code/Java/Database-SQL-JDBC/DemoResultSetOracle.htm</a></p>
<p>Don&#8217;t know what this next one is but it looks important <img src='http://freddysmind.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/refcur/index.html">http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/refcur/index.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://freddysmind.com/blog/2009/10/oracle-sql-result/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
