<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>ORA-Error on A Blog on Oracle and Stuff</title>
    <link>https://enesi.no/tag/ora-error/</link>
    <description>Recent content in ORA-Error on A Blog on Oracle and Stuff</description>
    <image>
      <title>A Blog on Oracle and Stuff</title>
      <url>https://enesi.no/images/enesi_logo.jpg</url>
      <link>https://enesi.no/images/enesi_logo.jpg</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Enesi Consulting AS</copyright>
    <lastBuildDate>Tue, 21 Feb 2023 18:22:48 +0100</lastBuildDate>
    <atom:link href="https://enesi.no/tag/ora-error/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>ORA-01821</title>
      <link>https://enesi.no/2023/02/ora-01821/</link>
      <pubDate>Tue, 21 Feb 2023 18:22:48 +0100</pubDate>
      <guid>https://enesi.no/2023/02/ora-01821/</guid>
      <description>&lt;h2 id=&#34;ora-01821&#34;&gt;ORA-01821&lt;/h2&gt;
&lt;p&gt;Why does this SQL fail?&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;SELECT&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TO_DATE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;10-Sep-02 14:10:10.123000&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;DD-Mon-RR HH24:MI:SS.FF&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;FROM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DUAL&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The example is from the 19c SQL Language Reference, with a slight change. The format is valid, but the thing is that the DATE data type does not support fractions of seconds. Therefore the last part of the format string is unknown to the TO_DATE-function.&lt;/p&gt;
&lt;p&gt;One day I lost a few minutes because I stared at the format string too long before I noticed that I was using TO_DATE instead of TO_TIMESTAMP.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="ora-01821">ORA-01821</h2>
<p>Why does this SQL fail?</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">SELECT</span><span class="w"> </span><span class="n">TO_DATE</span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;10-Sep-02 14:10:10.123000&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;DD-Mon-RR HH24:MI:SS.FF&#39;</span><span class="p">)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="k">FROM</span><span class="w"> </span><span class="n">DUAL</span><span class="w">
</span></span></span></code></pre></div><p>The example is from the 19c SQL Language Reference, with a slight change. The format is valid, but the thing is that the DATE data type does not support fractions of seconds. Therefore the last part of the format string is unknown to the TO_DATE-function.</p>
<p>One day I lost a few minutes because I stared at the format string too long before I noticed that I was using TO_DATE instead of TO_TIMESTAMP.</p>
<p>The data type for the column I was inserting data into was indeed DATE, but the string I had to convert had these fractions of seconds, which sidetracked me. I was too focused on transforming the entire string and getting the format right that I forgot to look at the bigger picture.</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
