存储过程为:
--存储过程(分页)
create or replace procedure p7(v_table in varchar2,v_pagesize in number,
v_pagenow in number,v_result out pac2.songCursor) is
v_start number;
v_end number;
v_sql varchar2(2000);
begin
v_start:=v_pagesize*(v_pagenow-1)+1;
v_end:=v_pagesize*v_pagenow;
v_sql:='select a2.* from (select a1.*,rownum rn from (select * from '||v_table||' a1) where rownum <'||v_end||') a2 where rn>'||v_start;
open v_result for v_sql;
end;
eclipse里面为:
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@10.1.12.191:1521:orcl";
ct=DriverManager.getConnection(url,"system","manager");
cs=ct.prepareCall("{call p7(?,?,?,?)}");
cs.setString(1,"login" );
cs.setInt(2,3);
cs.setInt(3,1);
cs.registerOutParameter(4, oracle.jdbc.OracleTypes.CURSOR);
cs.execute();
rs=(ResultSet)cs.getObject(4);
while(rs.next()){
System.out.println("name="+rs.getString("name")+" no="+rs.getInt("no"));
}
错误为:ava.sql.SQLException: ORA-00904: "A1": 标识符无效
ORA-06512: 在 "SYSTEM.P7", line 10
ORA-06512: 在 line 1
不知道是那个标识符了
------解决方案--------------------
你 a1后面的括号应该写在前面吧。。。。
------解决方案--------------------
楼上正解!
------解决方案--------------------
楼上说对了
代码迷推荐解决方案:oracle存储过程,http://www.daimami.com/search?q=177537