oracle 循环插入变量,oracle 循环插入数据

--建表

--drop table SalesList;

create table SalesList(

keHu varchar2(20), --客户

shangPin varchar2(20), --商品名称

salesNum number(8) --销售数量

);

--插入数据

declare

--谈几个客户

cursor lr_kh is

select regexp_substr('张三、李四、王五、赵六','[^、]+',1, level) keHu from dual

connect by level <= 4;

--进点货

cursor lr_sp is

select regexp_substr('上衣、裤子、袜子、帽子','[^、]+',1, level) shangPin from dual

connect by level <= 4;

begin

--循环插入

for v_kh in lr_kh loop

for v_sp in lr_sp loop

insert into SalesList

select v_kh.keHu, v_sp.shangPin, floor(dbms_random.value(10,50)) from dual;

end loop;

end loop;

commit;

end;

/

标签:20,level,varchar2,插入,循环,oracle,table,keHu

来源: https://www.cnblogs.com/iupoint/p/10997207.html

你可能感兴趣的:(oracle,循环插入变量)