sqlplus中建立如下的内容:
1、程序包
SQL> create or replace package types
2 as
3 type cursorType is ref cursor;
4 end;
5 /
程序包已创建。
2、函数
SQL> create or replace function sp_ListEmp return types.cursortype
2 as
3 l_cursor types.cursorType;
4 begin
5 open l_cursor for select id, title from cf_news order by id;--表的名字
6 return l_cursor;
7 end;
8 /
函数已创建。
3、过程
SQL> create or replace procedure getemps( p_cursor in out types.cursorType )
2 as
3 begin
4 open p_cursor for select id, title from cf_news order by id;--表的名字
5 end;
6 /
过程已创建。
4、建立一个可执行的java控制台程序
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
class GetValues
{