Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to do a conversion if your session parameter '<strong>NLS_DATE_FORMAT</strong>' is not '<strong>mm/dd/yyyy</strong>'.</p> <p>For example:</p> <pre><code>create table myTbl (id number, cdat date); select * from nls_session_parameters ns where ns.parameter = 'NLS_DATE_FORMAT'; PARAMETER VALUE ------------------------------------------------------- NLS_DATE_FORMAT DD-MON-RR </code></pre> <p>In this case, without a to_Date you'll get an error:</p> <pre><code>insert into myTbl values (123, '12/05/2011'); ORA-01843: not a valid month </code></pre> <p>You can change this paramter at session level, system level, etc.</p> <pre><code>zep@dev&gt; alter session set NLS_DATE_FORMAT = 'mm/dd/yyyy'; Session altered select * from nls_session_parameters ns where ns.parameter = 'NLS_DATE_FORMAT'; PARAMETER VALUE ------------------------------------------------------------------------------------- NLS_DATE_FORMAT mm/dd/yyyy insert into myTbl (id, cdat) values (123, '12/05/2011'); 1 row inserted zep@dev&gt; select * 2 from myTbl; ID CDAT ---------- ----------- 123 05/12/2011 </code></pre> <hr> <p><strong>Test on a row level trigger</strong></p> <pre><code>truncate table Mytbl; alter session set NLS_DATE_FORMAT = 'DD-MON-RR'; create or replace trigger befins_myTbl before insert on myTbl for each row declare begin -- demo :new.cdat := :new.cdat + numtoyminterval(1,'YEAR');-- (demo trigger add 1 year ) end; insert into myTbl (id, cdat) values (123, '12/05/2011'); </code></pre> <p><strong>Output</strong>: ORA-01843: <strong>not a valid month</strong></p> <pre><code>alter session set NLS_DATE_FORMAT = 'mm/dd/yyyy'; insert into myTbl (id, cdat) values (123, '12/05/2011'); commit; select * from myTbl; </code></pre> <p>Output</p> <pre><code>ID CDAT ---------- ----------- 123 12/05/2012 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload