PL/SQL - ORACLE: ORA-01843: not a valid month
<p>I would like to insert data in a table with a timestamp column inside a PL/SQL ETL process on a oracle database Version 11.2.0.4 </p>

<p>IF I run "Create INSERT from seletcted row" in Toad I get the following SQL Command:</p>

<pre><code> Insert into xxxx$1
   (ID, ITEM, ITEMSIZE, QUALITY, MATERIAL, 
    COLOUR, IMAGEURL, CREATIONDATE, SAMPLEITEMNUMBER, ITEMNUMBER)
 Values
   (111, 339079775, '1', 'Microfaser PRIMABELLE®', 'TEXTILE', 
    '1 (=creme)', 'url', TO_TIMESTAMP('27.06.2016 15:49:35.000000','DD.MM.YYYY HH24:MI:SS.FF'), 'xxx', 'xxxx');
COMMIT;
</code></pre>

<p>In PL/SQL I generate a VARCHAR2/String which looks like the same way:</p>

<pre><code>v_sql :=
                                'INSERT INTO xxxx'
                             || p_importpostfix
                             || '  VALUES ('
                             || seq_xxxx.NEXTVAL
                             || ','
                             || v_rec.item_id
                             || ', '''
                             || v_size
                             || ''','''
                             || v_quality
                             || ''','''
                             || v_material
                             || ''','''
                             || v_colour
                             || ''','''
                             || NULL
                             || ''',to_timestamp('''|| to_char( sysdate, 'DD.MM.YYYY HH24:MI:SS')||''',''DD.MM.YYYY HH24:MI:SS.FF''),'''
                             || v_rec.vid
                             || ''','''
                             || v_rec.vid
                             || ''')';
</code></pre>

<p>If I run the procedure singulary outside the whole process, it works fine.
No errors occur.</p>

<p>If I run the complete process started by a database JOB I will get an ORACLE: </p>

<blockquote>
  <p>ORA-01843: not a valid month error.</p>
</blockquote>

<p>I have read the other thread with this issue without understanding the problem in my case. </p>