创建hello world存储过程
文件-新建-程序窗口-产品
单击确定以创建代码
createorreplaceprocedurep _ hello is
-在此定义变量
比根
DBMS _ output.put _ line (' hello world!' );
endp_hello;
测试存储过程,创建新的测试窗口,然后调用存储过程。
2 .存储过程
输入、输出类型
自定义参数类型
引用表字段的参数类型
过程函数的调用
看结果:
使用java调用oracle存储过程
@Test
publicvoidcallprocedure throws exception { }
long start=system.current time millis (;
//设置驱动器
class.forname (驱动程序;
//创建链接
connection conn=driver manager.getconnection (dburl,name,password );
//关闭自动提交
conn.set自动提交(false );
callablestatementcst=conn.prepare call (' { callp _ use table )? () );
CST.setstring(1,'撒娇香菇');
CST.set int (2,13 );
//登录输出参数
CST.registeroutparameter(3,Types.VARCHAR );
cst.execute (;
system.out.println (CST.getstring (3) );
conn.commit (;
conn.close (;
system.out.println (system.current time millis (-start );
}
输出结果: