举例存储结构

3 篇文章 0 订阅
2 篇文章 0 订阅
create proc nopasscount
@count int output,
@writtenpass int,
@labpass int
as
begin
select  @count=count(*) from stumarks where
writtenexam < @writtenpass or labexam<@labpass
end
go

declare @sum int
exec nopasscount @sum output,60,60
print '及格的人数' +couvert(varchar(2),@sum)

create proc nopassinfo
@writtenpass int,
@labpass int,
as
begin
select * from stuinfo inner join stumarks
on stuinfo.stuno=stumarks.stuno where
stumarks.writtenexam < @writtenpass or
stumarks.labexam < @labpass
end
go
exec nopassinfo 60,60

CallableStatement callStmt=null;
ResultSet rs=null
try{
   conn = DriveManager.getConnection("");
   callStmt = conn.prepareCall("{call nopassinfo(?,?)}");
   callStmt.setInt(1,60);
   callStmt.setInt(2,60);
//如果存储过程可以执行
if(callStmt.execute()){
     rs=callStmt.getResultSet();
    syso(rs.getString(1));
}catch(SQLException e){
e.printStackTrace();
}
  rs.close();
  callStmt.close();
  conn.close();
}
存储过程
执行一个任务,该任务包括了一系列的PL/SQL语句,存储在数据库中,成为数据库一个对象。
效率比较高的,但你创建一个存储过程它会进行一个判断编译的.

只带一个输入参数,把查询的结果显示出来
create or replace procedure xs_proc(temp_id in integer)
is
name varchar2(25);
begin
  select xing_ning into name from xue_sheng where id=temp_id;
  DBMS_OUTPUT.PUT_LINE(name);
END;
/

create or replace procedure xs_proc(empno in integer)
is
name varchar2(25);
begin
  select xing_ning into name from xue_sheng where id=temp_id;
  DBMS_OUTPUT.PUT_LINE(name);
END;
/


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值