27 lines
650 B
MySQL
27 lines
650 B
MySQL
|
|
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;
|
||
|
|
/
|
||
|
|
|