易截截图软件、单文件、免安装、纯绿色、仅160KB

jdbc中调用oracle函数

1、创建表
 create table stud(
 sid int,
 sname varchar2(50),
 age number,
 score number(4,2))
并插入一些数据(自己手动插入一些吧)
2、创建函数
create or replace function fun_getScores(
       v_age in stud.age%type
)
return number
is
       v_score number;
begin
      
       select sum(score) into v_score from stud where age > v_age;
       return v_score;
      
--异常处理
exception
       when others then
       dbms_output.put_line(sqlcode||sqlerrm);
       return -1;
end;
3、jdbc中调用
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Types;
public class TestFun {
 public void test(){
 
  Connection con = null;
  Statement st = null;
  ResultSet rs = null;
  CallableStatement cst = null;
  try{
   Class.forName("oracle.jdbc.driver.OracleDriver");
   //下面的tan是数据库名,默认是orcl,love是访问密码,默认是tiger,
          //1521是端口号,默认是1521
   con = DriverManager.getConnection
("jdbc:oracle:thin:@192.168.1.103:1521:tan","scott","love");
   String sql =  "{? = call fun_getScores(?)}";
   cst = con.prepareCall(sql);
   cst.registerOutParameter(1, Types.NUMERIC);
   cst.setDouble(2, 2);
   cst.execute();
   double result = cst.getDouble(1);
   
   System.out.println("年龄超过2岁学生的成绩总和 "+result);
  }catch(Ex


相关文档:

oracle 进程 会话,游标,事务的关系

oracle 进程 会话,游标,事务的关系
如果在LINUX 下 是用TOP 可以看到正在跑的ORACLE 进程。ORACLE 除了后台进程外还有用户进程。
既是开启了并行,也是单独的进程。
PL/SQL DEVELOPER 里的多个查询窗口实际上是进程。
一个进程可以包含多个会话,当它们只能串行运行。比如在一个查询窗口中执行三个SELECT查询。
下面 ......

oracle练习(mldn视频课程)四

视图
创建新表:create table emp2 as select * from emp;
create view empv20 as select empno,ename,job,hiredate,deptno from emp where deptno=20 with check option;
语法:create or replace view 视图名称 as 子查询(修改之后的子查询)
替换视图(修改)
create or replace view empv20 as select empno,ename, ......

oracle job号使用

当用submit建JOB时,JOBID由系统自带SEQUENCE:sys.JOBSEQ生成。
如果一段时间后JOBID过大,可以DROP SEQUENCE sys.JOBSEQ;再重建
create sequence JOBSEQ
minvalue 1
maxvalue 999999999999
start with 1
increment by 1
cache 20;
来重新开始JOBID。
可以用下面语句更新已经建立的JOBID:
UPDATE sys.Job$
SE ......

oracle下载地址 for linux or windows


Oracle9i Database Release 2 Enterprise/Standard/Personal Edition for Windows NT/2000/XP
http://download.oracle.com/otn/nt/oracle9i/9201/92010NT_Disk1.zip
http://download.oracle.com/otn/nt/oracle9i/9201/92010NT_Disk2.zip
http://download.oracle.com/otn/nt/oracle9i/9201/92010NT_Disk3.zip
Oracle9i ......

Oracle在windows下安装纪要


安装:
运行G:\install\setup.exe安装Oracle,但不创建启动数据库
创建数据库(使用Configuration And Migration Tools->DataBase Configuration Assistant)
创建监听程序(使用Configuration And Migration Tools->NetManager或者 Configuration And Migration Tools->Net Configuration Assistant)
创建服务 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号