101:要求:写一个存储过程 usp_InsertATMUsersData,
对 userInfo 表模拟插入用户记录,
每种用户类型(ATM 取款机,营业员)各 5 条(要求使用循环)
/创建表:/
create table userinfo –操作员,atm机器信息表
(userid number not null, –操作员编号,unique identifier,主键
usertype varchar2(20) not null, –操作员类型,必填,atm取款机,营业员
code varchar2(50) –代号信息 操作员或营业员工号 );
/营业员编号的序列生成:1开头的四位数字/
create sequence yyy_seq
start with 1000
increment by 1
maxvalue 1999
minvalue 1000
nocycle
cache 5
/ATM取款机编号的序列的生成:2开头的四位数字/
create sequence qkj_seq
start with 2000
increment by 1
maxvalue 2999
minvalue 2000
nocycle
cache 5
/创建存储过程:/
create or replace procedure usp_InsertATMUsersData
as
i number default 1;
v_yyy userinfo.userid%type;
v_qkj userinfo.userid%type;
yyy_code userinfo.code%type;
qkj_code userinfo.code%type;
begin
while i<=5 loop
i:=i+1;
select yyy_seq.nextval into v_yyy from dual;
yyy_code :=’营业员’||v_yyy;
insert into userinfo(userid,usertype,code)
values (v_yyy,’营业员’,yyy_code);
select qkj_seq.nextval into v_qkj from dual;
qkj_code :=’ATM取款机’||v_qkj;
insert into userinfo(userid,usertype,code)
values (v_qkj,’ATM取款机’,qkj_code);
end loop;
end;
存储过程已创建,调用:
call usp_InsertATMUsersData();
select * from userinfo;
==========================================
102:要求:写一个存储过程 usp_InsertATMCustomerData,
对 customerInfo 表模拟插入客户记录 3 条(要求使用循环) ———每次执行加入三条记录*/
/创建表/
create table customerinfo –客户信息表
( customerid integer default 1, –顾客编号,自动编号(标识列),从开始,主键
customername varchar2(20) not null, –开户名必填
pid cha