<?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>lstierneyltd &#187; oracle</title>
	<atom:link href="http://lstierneyltd.com/blog/tag/oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://lstierneyltd.com/blog</link>
	<description>Yet another development blog</description>
	<lastBuildDate>Wed, 13 Jul 2011 12:55:13 +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>View Source of Oracle Trigger</title>
		<link>http://lstierneyltd.com/blog/development/tips/view-source-of-oracle-trigger/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/view-source-of-oracle-trigger/#comments</comments>
		<pubDate>Wed, 11 May 2011 12:09:09 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[quick tips]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=257</guid>
		<description><![CDATA[select trigger_body from user_triggers where trigger_name = 'XXXXX']]></description>
			<content:encoded><![CDATA[<pre>
select trigger_body from user_triggers where trigger_name = 'XXXXX'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/view-source-of-oracle-trigger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Oracle&#8217;s SYS_GUID()</title>
		<link>http://lstierneyltd.com/blog/development/using-oracles-sys_guid/</link>
		<comments>http://lstierneyltd.com/blog/development/using-oracles-sys_guid/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 12:28:26 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=250</guid>
		<description><![CDATA[Background For years I&#8217;ve bemoaned Oracle&#8217;s lack of an auto-number/identity type column (think MySQL AUTO_INCREMENT). Obviously you can create sequences and triggers to produce the same effect but it always seemed like a bit of a palaver to me. So, I had a smile on my when I discovered the delight that is SYS_GUID(). Taken [...]]]></description>
			<content:encoded><![CDATA[<h3>Background</h3>
<p>For years I&#8217;ve bemoaned Oracle&#8217;s lack of an auto-number/identity type column (think MySQL AUTO_INCREMENT). Obviously you can create sequences and triggers to produce the same effect but it always seemed like a bit of a palaver to me. </p>
<p>So, I had a smile on my when I discovered the delight that is SYS_GUID().</p>
<p>Taken from the <a href="http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/functions153.htm" target="_blank">Oracle documentation</a>:</p>
<blockquote><p>
SYS_GUID generates and returns a globally unique identifier (RAW value) made up of 16 bytes. On most platforms, the generated identifier consists of a host identifier, a process or thread identifier of the process or thread invoking the function, and a nonrepeating value (sequence of bytes) for that process or thread.
</p></blockquote>
<h3>Example</h3>
<pre class="brush: sql; title: ; notranslate">
select SYS_GUID() from dual

  SYS_GUID()
= ================================
1 A20D42BA1F165DB5E04400144FB99F0A
</pre>
<h3>SYS_GUID() as a default</h3>
<p>Because SYS_GUID() &#8220;returns a globally unique identifier&#8221; we can use it as a default value in a Primary Key column of a table.</p>
<pre class="brush: sql; title: ; notranslate">
create table products(
    product_id raw(32) default sys_guid() not null primary key
    ............
);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/using-oracles-sys_guid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Ibatis Typehandlers to fix Oracle Date &#8220;missing time&#8221;</title>
		<link>http://lstierneyltd.com/blog/development/examples/using-ibatis-typehandlers-to-fix-oracle-date-missing-time/</link>
		<comments>http://lstierneyltd.com/blog/development/examples/using-ibatis-typehandlers-to-fix-oracle-date-missing-time/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 11:25:44 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[ibatis]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=160</guid>
		<description><![CDATA[The Problem When using Ibatis to retrieve Date type values, on Oracle 10g (some driver versions), the time portion of the value returned from the database is not mapped onto the Java object. i.e. In DB: 02-JAN-10 13:30:00 In Java Object after mapping: 02-JAN-10 00:00:00 The Ibatis ResultMapper, snippet, looks like this: .... &#60;result property="savedDate" [...]]]></description>
			<content:encoded><![CDATA[<h4>The Problem</h4>
<p>When using Ibatis to retrieve Date type values, on Oracle 10g (some driver versions), the time portion of the value returned from the database is not mapped onto the Java object.</p>
<p>i.e.</p>
<p>In DB: <strong>02-JAN-10 13:30:00</strong><br />
In Java Object after mapping: <strong>02-JAN-10 00:00:00</strong></p>
<p>The Ibatis ResultMapper, snippet, looks like this:</p>
<pre>
....
&lt;result property="savedDate" column="SAVED_DATE" javaType="java.util.Date" jdbcType="DATE"/&gt;
....
</pre>
<p><code><span id="more-160"></span></code></p>
<h4>The Solution</h4>
<p>1. Implement our old friend the Ibatis TypeHandlerCallback.</p>
<pre class="brush: plain; title: ; notranslate">
package foo.bar;

import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;

import com.ibatis.sqlmap.client.extensions.ParameterSetter;
import com.ibatis.sqlmap.client.extensions.ResultGetter;
import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;

public class CustomDateHandler implements TypeHandlerCallback {

    public Object getResult(ResultGetter getter) throws SQLException {
        final Object obj = getter.getTimestamp();
        return obj != null ? (Date) obj : null;
    }

    public void setParameter(ParameterSetter setter,Object value) throws SQLException {
        setter.setTimestamp(value != null ? new Timestamp(((Date)value).getTime()) : null);
    }

    public Object valueOf(String datetime) {
        return Timestamp.valueOf(datetime);
    }
}
</pre>
<p>2. Add Typehandlers and TypeAliases to Ibatis config</p>
<pre>
&lt;typeAlias alias="OracleDateHandler" type="foo.bar.CustomDateHandler"/&gt;
&lt;typeHandler callback="OracleDateHandler" jdbcType="DATETIME" javaType="date"/&gt;
</pre>
<p>3. Update resultMap to use new &#8220;type&#8221;</p>
<pre>
....
&lt;result property="savedDate" column="SAVED_DATE" javaType="java.util.Date" jdbcType="DATETIME"/&gt;
....
</pre>
<h4>Important Note!</h4>
<p>This solution deals with issues caused by certain versions of the Oracle JDBC drivers. I believe that the 11g drivers fix this issue. As ever YMMV&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/examples/using-ibatis-typehandlers-to-fix-oracle-date-missing-time/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to convert a CLOB to an XMLType in Oracle</title>
		<link>http://lstierneyltd.com/blog/development/tips/how-to-convert-a-clob-to-an-xmltype-in-oracle/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/how-to-convert-a-clob-to-an-xmltype-in-oracle/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 13:17:23 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[plsql]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=125</guid>
		<description><![CDATA[Not much comment to add here; code says it all PROCEDURE clobToXMLType(myClob IN CLOB) IS l_xmlType XMLTYPE; -- do something BEGIN l_xmltype := XMLTYPE.createXML(myClob); EXCEPTION WHEN OTHERS THEN RAISE; END clobToXMLType;]]></description>
			<content:encoded><![CDATA[<p>Not much comment to add here; code says it all</p>
<pre>
PROCEDURE clobToXMLType(myClob IN CLOB)

IS
    l_xmlType XMLTYPE;
    -- do something
BEGIN
    l_xmltype := XMLTYPE.createXML(myClob);

EXCEPTION

    WHEN OTHERS THEN
    	RAISE;

END clobToXMLType;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/how-to-convert-a-clob-to-an-xmltype-in-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

