Insert random numbers through Precedent

Asked

Viewed 26 times

-1

I am trying to insert some random record into a table but am encountering some errors.

I created a test table; `create table teste_p(Handle int, name varchar(20));

I need to insert something like:

create or replace(

i number;

Begin for i in 1 .. 10 loop

Insert into socpro.teste_p(Handle,name) values (here random numbers using dbms.random.value, here random string using dbms.random.string)

end loop;

commit;

end;)

1 answer

0

--sequencia artificial
SELECT LEVEL 
FROM DUAL CONNECT BY LEVEL <= 10;

--COM ALEATORIOS
SELECT LEVEL handle ,DBMS_RANDOM.STRING('U',20) nome  
FROM DUAL CONNECT BY LEVEL <= 10;

--COM INSERT
INSERT INTO teste_p
 SELECT LEVEL handle ,DBMS_RANDOM.STRING('U',20) nome  
 FROM DUAL CONNECT BY LEVEL <= 10;

doc

Browser other questions tagged

You are not signed in. Login or sign up in order to post.