数据库对象管理3
一、表
二、索引
三、视图
四、同义词
五、序列
(1. 表、2. 索引、3. 视图、4. 同义词、5. 序列见数据库对象管理)
六、函数
七、过程
八、触发器
(6.函数、7.过程、8.触发器见数据库对象管理2)
九、包
dbms_output.put_line
包:dbms_output
过程/函数:put_line
包头:声明对象(函数、过程、游标)
包体:实现对象
9.1 自定包,包含一个过程和函数
包的调用:
9.2 登录案例库,定义包mypackage11,包含一个过程p_emp,用游标循环输出员工的工号、姓名、薪水;和一个函数p_count,统计某个部门的总人数。
调用:
9.3 JSP 调用过程/函数
第一步定义过程:
第二步通过 JSP 调用过程:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String password="tiger";
Connection con=DriverManager.getConnection(url,user,password);
String procedure="{call p_statis11()}";
CallableStatement cstmt=con.prepareCall(procedure);
cstmt.executeUpdate();
Statement st=con.createStatement();
String sql="select * from statis11";
ResultSet rs=st.executeQuery(sql);
%>
<table border=1>
<tr>
<th>平均工资</th>
<th>最高工资</th>
<th>最低工资</th>
</tr>
<% while(rs.next()){ %>
<tr>
<td><%=rs.getString(1) %></td>
<td><%=rs.getString(2) %></td>
<td><%=rs.getString(2) %></td>
</tr>
<%
}
rs.close();
st.close();
%>
</table>
</body>
</html>