存储过程对象

时间:2022-05-18 14:18:19 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
存储过程对象

SQL> create table account(accunt_id varchar2(5),name varchar2(10),sum number(10,2); SQL> insert into account values(10001,tom,5000); SQL> insert into account values(10002,kate,0); SQL> select * from account;

模拟银行转账 create or replace procedure pro_zz(zc_zh in varchar2,zr_zh in varchar2, zz_je in int) as var_sum int:=0 begin select sum into var_sum from account where account_id=zc_zh; if var_sum dbms_output.put_line(meiqianle!); else update account set sum=sum-zz_je where account_id=zc_zh; dbms_outpuyt.put_line(zhuangchuchenggong!); update account set sum=sum+zz_je where account_id=zr_zh; dbms_outpuyt.put_line(zhuangchuchenggong!); commit; end if; end; /

(zc_zh 转出帐号,zr_zh 转入帐号, zz_je转账金额) SQL> set serveroutput on 显示过程 SQL> exec pro_zz(10001,10002,10000);

公司财务分析 统计公司月销量金额,盈利金额,库存 1. 创建表 tt,tt2

SQL> select * from tt; 缺交易时间SJ CP DJ SL SJ A B C A b

100 200 500 100 200

5 5 6 10 15

2012-12-12 12:12:12 2012-12-15 12:12:12 2012-12-05 12:12:12 2011-12-25 12:12:12 2012-12-25 12:12:12

a产品 总额 单价*数量 本月 select distinct from tt where cp=a;

select sum(sl) from tt where to_char(sj,yyyy-mm)=2012-12 and cp=a; SQL> select * from tt2;


CP a b c

ZL 1000 1000 1000

2. 创建存储过程

SQL> create or replace procedure pro_bb as a1 int:=0; a2 int:=0; a3 int:=0; begin

select distinct dj*(select sum(sl) from tt here to_char(sj,yyyy-mm)=2012-12 and cp=a) into a1 from tt where cp=a;

select distinct dj*(select sum(sl) from tt here to_char(sj,yyyy-mm)=2012-12 and cp=b) into a2 from tt where cp=b;

select distinct dj*(select sum(sl) from tt here to_char(sj,yyyy-mm)=2012-12 and cp=c) into a3 from tt where cp=c;

dbms_output.put_line(a1*0.2+a2*0.3+a3*0.1) /* 更新需要指定时间来执行 */

update tt2 set zl=zl-(select sum(sl) from tt where cp=a) where cp=a; update tt2 set zl=zl-(select sum(sl) from tt where cp=b) where cp=b; update tt2 set zl=zl-(select sum(sl) from tt where cp=c) where cp=c; dbms_output.put_line(tt2gengxin);

end; /

高考查分系统 t1 分数 t2 学校信息 1 登录系统:判断考号是否存在

SQL> create or replace procedure gk_login as num varchar2; name varchar2; begin select t.sum into num,t.sname into name from stu_info t where

t.snum='2009030703' and t.sname='liubingjie';





if num!=NULL then

dbms_output.put_line(dengluchenggong);









else dbms_output.put_line(denglushibai);

endif

end;

/ 2 总分

select distinct a.snum,sum(a.oscore) from stu_score a where


a.snum='2009030703' group by a.snum;

3 志愿那个被录取了



想出一个可以实现的新功能?

模式(Schema



用户下所有对象的集合

用户创建的同时模式即被创建 一个用户只能对应一个模式 用户与模式通常是指一个意思




本文来源:https://www.wddqw.com/doc/6f83bef75bf5f61fb7360b4c2e3f5727a5e924c8.html