我有一个程序
USE [ER]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[PKG_ER_SEL$sp_ERGetOrgDetails]
@v_OrgId int = NULL,
@v_Email varchar(max) = NULL,
@cv_1 varchar(8000) OUTPUT
AS
BEGIN
BEGIN TRY
SET @cv_1 = NULL
SELECT
o.ORGID,
o.NAME,
o.PHONE,
o.URL,
o.CURRENCY,
o.MEASUREMENT,
o.ISACTIVE,
u.FIRSTNAME,
u.LEVELID,
u.APPROVALLIMIT,
u.USERID,
u.MANAGERID
FROM
dbo.ER_ORGANIZATIONS AS o
JOIN dbo.ER_USERS AS u
ON o.ORGID = u.ORGID
WHERE
o.ORGID = @v_OrgId AND
u.EMAIL = @v_Email AND
u.ISACTIVE = 1
ORDER BY u.LEVELID
END TRY
BEGIN CATCH
BEGIN
PRINT 'System Error: Unhandled error occured during execution of sp_ERGetOrgDetails procedure, Please contact your administrator'
END
END CATCH
END
==================================================== ===================
我正在尝试从此过程中获取值,该过程返回 4 条记录。
我的java编是-
public static void getOrgDetails1(int orgId, String email){
Connection con =null;
try{
CallableStatement cs=null;
con = SqlConnectionManager.getConnection();
cs = con.prepareCall("{call PKG_ER_SEL$sp_ERGetOrgDetails(?,?,?)}");
cs.setInt(1,orgId);
cs.setString(2, email);
cs.registerOutParameter(3, java.sql.Types.VARCHAR); //cv_1
cs.execute();
String resultSet=cs.getString(3);
System.out.println(resultSet);
}catch(Exception e){
e.printStackTrace();
}finally{
SqlConnectionManager.releaseConnection(con);
}
}
当我运行这个 java prog 时,我得到的输出为 null,因为我期待 4 条记录,因此字符串中有一些值。
任何人都可以帮助我如何从 SQL Server 过程中获取值。