Stored procedure which returns multiple rows




















What is the intention of the unconditional raiserror? You might also consider a Function that outputs a table. Also - generally cursors are "bad" in sql-server poor overall performance.

If you can find a way to avoid cursors you'll have better performance. Add a comment. Active Oldest Votes. SQL Server does not need it. Improve this answer. I won't be able to achieve the results I need with a single select, the procedure I'm trying to recreate is a lot more involved — TheLovelySausage.

You can design your procedure however complex you like, I am just showing you the technology you will have to use under MS SQL: your final select returns the result set to the client. Is there any way to get those collection of records returned by the stored procedure using Informatica? It would be very appreciated if any of you can help me to solve this issue. Thanks Sree. Hi AR, Thanks for your suggestion.

But actually the stored procedure is returning a collection of records. The stored procedure transformation is a passive transformation, so its not able to handle many rows returned as a table type in one parameter.

Thats where I am facing the issue. The multiple rows is the least of your worries. How would you expect to interpret the object returned by the database? As AR suggested, have the SP write to a table.

However, you will need to split up your mapping. An initial mapping to execute the SP or maybe a pre-session call and a second mapping using the table loaded by the SP.

The following example calls the procedure created in the first example and saves the output value returned from the called procedure in the SalesYTD variable, which is local to the calling program. This allows the procedure to receive a value from the calling program, change or perform operations with the value, and then return the new value to the calling program.

Then in the procedure body, the value could be used for calculations that generate a new value. This is often referred to as "pass-by-reference capability. No error is returned, but you cannot use the output value in the calling program. The following rules pertain to cursor output parameters when the procedure is executed:.

For a forward-only cursor, the rows returned in the cursor's result set are only those rows at and beyond the position of the cursor at the conclusion of the procedure execution, for example:. The result set RS returned to the caller consists of rows from 6 through of RS, and the cursor in the caller is positioned before the first row of RS. For a forward-only cursor, if the cursor is positioned before the first row when the procedure exits, the entire result set is returned to the calling batch, procedure, or trigger.

When returned, the cursor position is set before the first row. For a forward-only cursor, if the cursor is positioned beyond the end of the last row when the procedure exits, an empty result set is returned to the calling batch, procedure, or trigger. It returns the ID of all Employees based on the City.

FROM Employees. Fetching multiple returned values from Stored Procedure. In order to fetch the multiple returned values from the Stored Procedure, you need to make use of a variable with data type and size same as the Output parameter and pass it as Output parameter using OUTPUT keyword.

You can also make use of the Split function to split the comma separated delimited values into rows. SplitString EmployeeIds , ','. Related Articles. Add Comments. Thank you for the feedback.



0コメント

  • 1000 / 1000