存储过程强化题:102-106

本文通过四个存储过程展示了数据库操作,包括插入用户记录、客户记录、卡记录以及模拟取款业务。涉及创建表、序列、存储过程,并在过程中处理数据验证和更新。
摘要由CSDN通过智能技术生成

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

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值