create or replace function calc_sort_key return raw deterministic
is
l_result raw(30) := hextoraw('41424344'); -- 'ABCD'
begin
return l_result;
end;
Function created.
select calc_sort_key from dual
| CALC_SORT_KEY | 41424344 |
|---|
select utl_raw.cast_to_varchar2(calc_sort_key) from dual
| UTL_RAW.CAST_TO_VARCHAR2(CALC_SORT_KEY) | ABCD |
|---|
select utl_raw.length(calc_sort_key) from dual
| UTL_RAW.LENGTH(CALC_SORT_KEY) | 4 |
|---|
create table x (
id number(38) primary key,
sort_key as (calc_sort_key())
)
Table created.
create unique index sort_key_ui on x (sort_key)
ORA-01450: maximum key length (6398) exceededMore Details: https://docs.oracle.com/error-help/db/ora-01450
drop table x
Table dropped.
create table x (
id number(38) primary key,
sort_key raw(30) as (calc_sort_key())
)
ORA-12899: value too large for column "SORT_KEY" (actual: 32767, maximum: 30)More Details: https://docs.oracle.com/error-help/db/ora-12899
create table x (
id number(38) primary key,
physical_column raw(30)
)
Table created.
create unique index physical_column_ui on x (physical_column)
Index created.
create or replace function calc_sort_key return x.physical_column%type deterministic
is
l_result raw(30) := hextoraw('41424344'); -- 'ABCD'
begin
return l_result;
end;
Function created.
alter table x add (
sort_key as (calc_sort_key())
)
Table altered.
create unique index sort_key_ui on x (sort_key)
ORA-01450: maximum key length (6398) exceededMore Details: https://docs.oracle.com/error-help/db/ora-01450