Files
oracle/my/random_data/STORE_random_02.sql
2026-03-12 21:23:47 +01:00

27 lines
650 B
SQL

declare
max_id_client NUMBER;
max_id_street NUMBER;
i NUMBER;
rand1 NUMBER;
rand2 NUMBER;
random_address VARCHAR2(50);
random_street VARCHAR2(40);
begin
select max(id) into max_id_client from CLIENT;
select max(id) into max_id_street from US_STREET;
for i in 1..max_id_client loop
rand1:=round(dbms_random.value(1,max_id_street));
rand2:=round(dbms_random.value(1,400));
select FULLNAME into random_street from US_STREET where ID=rand1;
random_address:=to_char(rand2)||' '||random_street;
update CLIENT set ADDRESS=random_address where ID=i;
end loop;
commit;
end;
/