59.59 GET_HASH Function
This function computes a hash value for all given values. Use this function to implement lost update detection for data records.
Syntax
APEX_UTIL.GET_HASH (
p_values IN apex_t_varchar2,
p_salted IN BOOLEAN DEFAULT TRUE )
RETURN VARCHAR2;
Parameters
Parameter | Description |
---|---|
p_values |
The input values. |
p_salted |
If TRUE (default), salt hash with internal session information. |
Example
This example updates the SAL and COMM columns of a given record in the EMP table, but throws an error if the column data has changed in the meantime.
declare
l_hash varchar2(4000);
begin
select apex_util.get_hash(apex_t_varchar2 (
empno, sal, comm ))
into l_hash
from emp
where empno = :P1_EMPNO;
if :P1_HASH <> l_hash then
raise_application_error(-20001, 'Somebody already updated SAL/COMM');
end if;
update emp
set sal = :P1_SAL,
comm = :P1_COMM
where empno = :P1_EMPNO;
exception when no_data_found then
raise_application_error(-20001, 'Employee not found');
end;
Parent topic: APEX_UTIL