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;
/