Search notes:

ORA-54002: only pure functions can be specified in a virtual column expression

The ORA-54002: only pure functions can be specified in a virtual column expression error is thrown when trying to specify a virtual column that uses non-deterministic functions.
create table tq84_ora_54002 (
   col_1   number,
   col_2   varchar2(3),
   now     as (sysdate)
);

REGEXP_REPLACE

Apparently, regexp_replace is not a deterministic function, the following create table statement throws a ORA-54002 error:
create table tq84_ora_54002 (
   mm_yy     varchar2(5),
   yyyy_mm   as (
      regexp_replace(mm_yy, '^(\d\d)\.(\d\d)$', '20\2 \1')
   )
);
It is possible, however, to create a deterministic function that calls regexp_replace:
create or replace function tq84_regexp_replace(
   val   varchar2,
   regex varchar2,
   subst varchar2
) return varchar2
  DETERMINISTIC
  authid definer
as
begin
   return regexp_replace(val, regex, subst);
end tq84_regexp_replace;
/
With this function, it is possible to create the table:
create table tq84_ora_54002 (
   mm_yy    varchar2(5),
   yyyy_mm   as (
      tq84_regexp_replace(mm_yy, '^(\d\d)\.(\d\d)$', '20\2 \1')
   )
);                           
Test data:
begin
 insert into tq84_ora_54002(mm_yy) values ('01.13');
 insert into tq84_ora_54002(mm_yy) values ('04.18');
 insert into tq84_ora_54002(mm_yy) values ('09.17');
 commit;
end;
/

select * from tq84_ora_54002;
Cleaning up
drop table tq84_ora_54002;

See also

Virtual columns
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...', 1758200926, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/errors/ORA-54002_only-pure-functions-can-be-specified-in-a-virtual-column-expression(97): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78