Search notes:

Oracle: Temporarily change an NLS setting in a session

The following simple anonymous PL/SQL block tries to demonstrate how an NLS setting can be temporarily changed and then reset to the previously active one.
declare
   nls_date_format varchar2(30);

begin

--
-- save the current nls_date_format.
--
   nls_date_format := sys_context('userenv','nls_date_format');

--
-- Change the nls_date_format setting.
-- Note that the format needs to be enclosed in double-quotes.
--
   dbms_session.set_nls('nls_date_format', '"dd.mm.rrrr"');

--
-- Print the current date in the active date format:
--
   dbms_output.put_line(sysdate);

--
-- Reset the nls_date_format setting
-- Note again the double-quotes.
--
   dbms_session.set_nls('nls_date_format', '"' || nls_date_format || '"');
end;
/

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759045149, '216.73.216.5', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/adminstration/init-parameters/nls/temporarily-change-NLS-setting-in-session(61): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78