I have the following stored procedure and my goal is to return a result set from it, using the query "select * from #justTmp"
create procedure spAddPerson
@ID int,
@Name nvarchar(50)
as
begin
create table #justTmp
(
num int primary key,
justName nvarchar(50)
)
if @ID in (select C.ContributorID
from Contributors C)
begin
insert into #justTmp
values (@ID, @Name)
end
select *
from #justTmp
end
And this is my java code
CallableStatement cstmt = null;
ResultSet rs = null;
cstmt=conn.prepareCall("{ call spAddPerson(?,?) }");
cstmt.setInt(1, 1);
cstmt.setString(2, "MyName");
cstmt.execute();
rs=cstmt.getResultSet();
int first=rs.getInt(1);
String second=rs.getString(2);
For some reason, whenever I run it, and the above stored procedure is called, I get an exception that says
The statement did not return a result set
when the
rs = cstmt.getResultSet()
code is executed.
Any idea how to fix this so a result set would return and not null?
Thanks in advance