| 发表于:2007-07-19 14:42:18 楼主 |
各位大虾,大家好! 小鸟遇到了一个问题。先来看程序,再来描述问题。 一、第一种情况 1、存储过程如下: --创建查询存储过程 use pubs go if exists(select * from sysobjects where name= 'proc_select ') drop procedure proc_select go create procedure proc_select @out int output as select @out = count(*) from employee go --查询存储过程测试 declare @out int EXEC proc_select @out output print @out go 二、第二种情况 --创建查询存储过程 use pubs go if exists(select * from sysobjects where name= 'proc_select ') drop procedure proc_select go create procedure proc_select @out int output as select * from employee select @out = count(*) from employee go --查询存储过程测试 declare @out int EXEC proc_select @out output print @out go 三、当时使用一下java程序操作存储过程的时候,输出参数确接受到了不同了值,先来看看java程序。 import java.sql.*; public class test { public static void main(string[] args) { try { class.forname( "sun.jdbc.odbc.jdbcodbcdriver "); connection con = drivermanager.getconnection( "jdbc:odbc:test "); string procname = "{call proc_select(?)} "; callablestatement smt = con.preparecall(procname); smt.registeroutparameter(1, types.integer); smt.EXECute(); int count = smt.getint(1); system.out.println(count); smt.close(); con.close(); } catch (exception e) { e.printstacktrace(); } } } 四、 (1)当我用第三部分java应用程序调用第一部分的存储过程的时候,输出参数的值为当前结果集的总行数,例如:结果集有43行,此时输出43。 (2)但是当我用第三部门java应用程序调用第二部分的存储过程的时候,输出参数的值始终为0。 请大虾求解,第一、二部分的存储过程就多了一条select * from employee语句。小鸟觉得是因为多个结果集产生的问题,也只是猜测,请各位大虾多多帮忙,解决此问题。 谢谢了。 |
|
|
|
|