0

Hello all,

i have SQL 2005 installed. i have written a table-valued function getdepartments() which is as below:

CREATE FUNCTION getdepartments() 
RETURNS @departments TABLE(
                                                  DNAME VARCHAR(25), 
                                                  DEPTID VARCHAR(10), 
                                                   DBONUS DECIMAL(7,2)) 
AS  
BEGIN 
           INSERT @departments SELECT * FROM DEPARTMENT; 
RETURN
 END

i need to invoke this statement from java program using JDBC.
for that i have written the following code in my java program.

try
{
	getConnection();       //to establish connection
	CallableStatement cStmt = conn_.prepareCall("{? = call getdepartments()}");
	cStmt.registerOutParameter(1,Types.BINARY);
	cStmt.executeQuery();
	rs = (ResultSet) cStmt.getObject(1);
}

but this code doesn't seem to work properly
i get an error saying "stored procedure getdepartments not found".
hence please let me know how to make a call to table-valued functions using JDBC


Thank you,
Lakshmi

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by peter_budo
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.