searchsanjaysharma
asked on
How to return 2 recordsets in java and how to refer them
I have a n s ql procedure which is rerturning 2 result sets. How to assign it to resultset.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why have you got two ResultSet and how are they related? If there's a good reason to return two (which frankly i doubt) then you can return ResultSet[]
ASKER
I am using Sql server. It is giving Incompatible type when i declare array of resultset
I've never heard about returning of ResultSet[] ?! But I'm agree that if there is a need of returning of ResultSet[], then there is something wrong in the design of the application.
ASKER
I mean to say what if the procedure has the following set of statements.
create procedure sp_get
as
begin
select uname,password where dept='cse'
select count(*) from dept
end
create procedure sp_get
as
begin
select uname,password where dept='cse'
select count(*) from dept
end
Those are two independent statements and are not returned by the procedure, just used in it.
It's OK. If he return them as out parameters then there is no problem to read them as I showed in my first comment. I think that it's normal and right.
Ignoring that the second parameter is not cursor, it is "Int".
I mean in the example "sp_get" that the author posted.
Ignoring that the second parameter is not cursor, it is "Int".
I mean in the example "sp_get" that the author posted.
It's OK. If he return them as out parameters then there is no problem to read them as I showed in my first comment. I think that it's normal and right.
Yes, 'if'. In the example posted nothing is returned.
I think that it's normal and rightThere, i have to disagree. If you can show me several examples of where more than one cursor is returned from a procedure or function, then i would reassess it.
The question asked is "How to return 2 recordsets IN JAVA" (my emphasis). The answer to that is to use ResultSet[], IF it seems legitimate
ASKER
tx
Your SP is most likely wrong