Search notes:

ORA-43918: This argument must be a literal

The ORA-43918: This argument must be a literal can occur when using the default … on conversion error clause to prevent ORA-01858: A non-numeric character was found instead of a numeric character.
alter session set nls_date_format = 'dd.mm.yyyy';
Check if we're running with the default value for cursor_sharing:
select
   value,
   default_value
from
   v$parameter
where
   name = 'cursor_sharing';
--   
-- VALUE     DEFAULT_VALUE
-- -------   -------------
-- EXACT     EXACT
The following query runs ok, as expected:
select
   dt,
   to_date(dt default null on conversion error, 'yyyy-mm-dd') dt_
from (
   select '2024-12-28'   dt from dual union all
   select 'no such date' dt from dual
);
--
-- DT           DT_                
-- ------------ -------------------
-- 2024-12-28   2024-12-28 00:00:00
-- no such date  
So does this:
select
   to_date(dt default null on conversion error, 'yyyy-mm-dd') dt_
from (
   select '2024-12-28'   dt from dual union all
   select 'no such date' dt from dual
);
--
-- DT_                
-- -------------------
-- 2024-12-28 00:00:00
--
When setting cursor_sharing to force
alter session set cursor_sharing = force;
… things change a bit. The following statement throws ORA-43918: This argument must be a literal:
select
   dt,
   to_date(dt default null on conversion error, 'yyyy-mm-dd')
from (
   select '2024-12-28'   dt from dual union all
   select 'no such date' dt from dual
);
Interestingly, this one runs ok:
select
   to_date(dt default null on conversion error, 'yyyy-mm-dd') dt_
from (
   select '2024-12-28'   dt from dual union all
   select 'no such date' dt from dual
);
--
-- DT_                
-- -------------------
-- 2024-12-28 00:00:00
--
We can use the cursor_sharing_exact hint so that this query runs ok:
select /*+ cursor_sharing_exact */
   dt,
   to_date(dt default null on conversion error, 'yyyy-mm-dd')
from (
   select '2024-12-28'   dt from dual union all
   select 'no such date' dt from dual
);

See also

ORA-43907: This argument must be a literal or bind variable.
Other Oracle error messages

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...', 1759474050, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/errors/ORA-43918_This-argument-must-a-literal(123): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78