File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes How to retrieve dynamic columns from stored procedure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to retrieve dynamic columns from stored procedure" Watch "How to retrieve dynamic columns from stored procedure" New topic
Author

How to retrieve dynamic columns from stored procedure

suresh midde
Greenhorn

Joined: Aug 22, 2008
Posts: 25
Hi ,

I was given a procedure which expects one value and retrieves me the list of columns which may vary depending upon the input parameter

CREATE PROCEDURE [FLX].[GETANS]
@ques VARCHAR(200) AS
BEGIN

// some code that creates a temp table which has the dynamic cols
create table #temp1(


SELECT * FROM #temp1
END


When I execute this procedure from db2, it is fetching me the records. I would like to invoke this stored procedure from java. How can I retrieve the output columns of the procedure from java as the columns may vary some times.

Regards
Suresh Midde
Santhosh ayiappan
Ranch Hand

Joined: Jan 30, 2007
Posts: 80

You can use the index of the column to get the records back. You dont need to depend on the column name.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retrieve dynamic columns from stored procedure