cancel
Showing results for 
Search instead for 
Did you mean: 

Sender Stored Procedure - ResultSet

Former Member
0 Kudos

I have a requirement where the sender stored procedure should return mutiple rows of data(MS SQL Server)

Can you help with the JDBC Stored Procedure Code which can return recordsets ?

Warm Regards,

Rahul J

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member206760
Active Contributor
0 Kudos

Result sets are what you get when you run a simple SELECT statement inside a stored procedure. Let's suppose you want a stored procedure to return a list of all the people with a given last name. The code for the stored procedure might look like this:

CREATE PROCEDURE dbo.GetPeopleByLastName (@LastName NVARCHAR(50))

AS

SELECT ContactID,

FirstName,

LastName

FROM Person.Contact

WHERE LastName = @LastName

ORDER BY ContactIDIf you just execute this stored procedure in SQL Server Management Studio you get a result set that looks like this:

EXEC dbo.GetPeopleByLastName @LastName = 'Alexander'

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

ContactID FirstName LastName

-


-


-


22 J. Phillip Alexander

23 Michelle Alexander

430 Mary Alexander

. . . { hiding a bunch of rows } . . .

19942 Morgan Alexander

(123 row(s) affected)

Former Member
0 Kudos

Hi Tarang,

So it means if a select statement returns multiple records then the stored procedure would return resultset.

Nothing special needs to be done in the stored procedure to return result set ?

Warm Regards,

Rahul J

former_member206760
Active Contributor
0 Kudos

yes u will not require Return resultset.

you will have to define the source data type as

<resultset>

<row>

<column-name1>column-value</ column-name1>

<column-name2>column-value</ column-name2>

<column-name3>column-value</ column-name3>

</row>

<row>

<column-name1>column-value</ column-name1>

<column-name2>column-value</ column-name2>

<column-name3>column-value</ column-name3>

</row>

</resultset>