FOR x IN (SELECT ID FROM TABLE_B ORDER BY ID)
LOOP
UPDATE TABLE_B
SET table_b."VALUE" = (SELECT MIN(TABLE_A."VALUE") KEEP (DENSE_RANK FIRST ORDER BY dbms_random.VALUE)
FROM TABLE_A
)
WHERE ID = TABLE_B.id;
END LOOP;
COMMIT;
END;
BEGIN insert into TABLE_B(ID, "VALUE")
with t as (
select
id,
min("VALUE") over() as min_val,
max("VALUE") over() as max_val
from TABLE_A)
select
id,
min_val + rand() * (max_val - min_val) as val
from t