Questions tagged [output-parameter]

output parameters allow stored procedures to return data to the calling code.

133 questions
32
votes
3 answers

ADO.NET calling T-SQL Stored Procedure causes a SqlTimeoutException

I have a T-SQL stored procedure with the signature CREATE PROCEDURE MyProc @recordCount INT OUTPUT @param1 INT ... When executed directly in Sql Server the procedure runs in under 5 seconds, returning a few result sets amounting to about 100 rows…
crowleym
  • 2,532
  • 3
  • 22
  • 28
13
votes
2 answers

Output parameter in stored procedure in EF

I have an existing database with lots of complex stored procedure and I want to use those procedure through EF 4. I have done the following: Created an EF data object, Customer. Added a Stored Procedure into the EF Right Click on the EF designer…
Chris
  • 2,293
  • 11
  • 48
  • 86
12
votes
2 answers

Is it bad practice to have an output parameter in a method in a WCF service?

I'm looking for reasons beyond the usual "out parameters are confusing and indicate the method is doing more than one thing"-style arguments and more about what is specifically bad about output parameters in WCF services. Where I work now, we have…
Duncan Edwards
  • 1,528
  • 2
  • 19
  • 32
11
votes
1 answer

How to get stored procedure output parameter into variable using Powershell?

I have a stored procedure returning a string and I need the result as a powershell variable. I'm stuck on the output parameter syntax. Powershell script: $SqlConnection = New-Object System.Data.SqlClient.SqlConnection $SqlConnection.ConnectionString…
scw
  • 5,450
  • 8
  • 36
  • 49
11
votes
3 answers

How to pass output parameter to a Stored Procedure?

I have written a stored procedure with the following format: ALTER PROCEDURE usp_data_migration (@sourceDatabase varchar(50), @sourceTable varchar(50), @targetDatabase varchar(50), @targetTable varchar(50), @finaloutput…
Yousuf Sultan
  • 3,055
  • 8
  • 35
  • 63
10
votes
5 answers

T-SQL stored procedure - Detecting if a parameter is supplied as OUTPUT

Consider the following T-SQL code snippet: CREATE PROC dbo.SquareNum(@i INT OUTPUT) AS BEGIN SET @i = @i * @i --SELECT @i END GO DECLARE @a INT = 3, @b INT = 5 EXEC dbo.SquareNum @a OUTPUT EXEC dbo.SquareNum @b SELECT @a AS ASQUARE, @b AS…
9
votes
5 answers

The Attribute. What useful purpose does is serve?

Under System.Runtime.InteropServices the Attribute exists. But what is it for? I would be glad if you could use the following example as base for your answers. Shared Sub Add(ByVal x As Integer, ByVal y As Integer, ByRef Result As…
OrElse
  • 9,709
  • 39
  • 140
  • 253
9
votes
1 answer

Output last inserted primary key value from stored procedure

I'm having a bit of difficulty with this one in that I'm not sure how to do this in SQL Server. Basically, I want to insert a new row into the database, get the PK value that was just inserted (same query) and output it back to whatever called the…
Ortund
  • 8,095
  • 18
  • 71
  • 139
7
votes
8 answers

Output Parameters in Java

With a third party API I observed the following. Instead of using, public static string getString(){ return "Hello World"; } it uses something like public static void getString(String output){ } and I am getting the "output" string assigned. I…
Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138
6
votes
4 answers

Retrieve output parameter of SQL statement

I'm using a table with two columns, customer_id and customer_name. customer_name is a simple varchar, customer_id is an auto incrementing primary key. I want to use my C# application to insert a customer_name, and retrieve the value of the…
Nattfrosten
  • 1,999
  • 4
  • 16
  • 21
6
votes
2 answers

Stored procedure output parameter returning rounded value

I'm using output parameters to return values from a stored procedure. Declaration in stored procedure is : @GrandTtl DECIMAL(19,3) OUT The SELECT query is: SET @GrandTtl = (SELECT TOP 1 Bill_Amount FROM…
5
votes
2 answers

How to get output parameters from MySQL stored procedure in Rails?

I'm trying to get a output parameter from MySQL stored procedure, let's have look a example below: 1 In mysql I created this procedure and it works. CREATE PROCEDURE sp_name (out id int) Begin select id into @id from table order by id desc limit…
user843910
5
votes
2 answers

Spring JDBCTemplate Stored Procedure with ResultSet and OutPut Parameter

I created a stored procedure which returns result rows and two output parameters. I am unable to find any thing in spring from which i can get ResultSet and outPutParameters. I want to achieve something like this using Spring framework.
5
votes
1 answer

Setting an output parameter to the value of count() in sql stored procedure

I have an output parameter @Counter and a temporary table #tmpUsers Is it possible to assign the value of SELECT COUNT(*) FROM #tmpUsers To the @Counter output parameter? I have tried SET @Counter = SELECT COUNT(*) FROM #tmpUsers But this…
Win
  • 2,593
  • 3
  • 25
  • 35
4
votes
1 answer

googlemock matcher for output parameters

I am testing whether my class calls a method on a mocked class, with the proper argument. I have set up a basic expectation: // mListener is a mocked object // This expectation accepts any argument EXPECT_CALL(this->mListener, OnChanged(_)) …
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
1
2 3
8 9