如何创建Java存储过程

来源:互联网 发布:苹果加密软件 编辑:程序博客网 时间:2024/06/05 02:47

一个创建使用java 存储过程的例子:

create or replace and compile
java source
named "MyTimestamp"
as
import java.lang.String;
import java.sql.Timestamp;
public class MyTimestamp
{
    public static String getTimestamp()
   {
     return(new Timestamp(System.currentTimeMillis())).toString();
   }
};
/
--注:注意java的语法,注意大小写

create or replace function my_timestamp return varchar2
as language java
name 'MyTimestamp.getTimestamp() return java.lang.String';
/

SQL>select my_timestamp,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') ORACLE_TIME from dual;

MY_TIMESTAMP             ORACLE_TIME

------------------------ -------------------

2003-03-17 19:15:59.688  2003-03-17 19:15:59