Questions tagged [out-parameters]
145 questions
6
votes
2 answers
How to circumvent using an out parameter in an anonymous method block?
The following method does not compile. Visual Studio warns "An out parameter may not be used within an anonymous method". The WithReaderLock(Proc action) method takes a delegate void Proc().
public Boolean TryGetValue(TKey key, out TValue value)
{
…

Anthony Mastrean
- 21,850
- 21
- 110
- 188
6
votes
3 answers
Is there any formal difference at all between PostgreSQL functions with OUT parameters and with TABLE results?
Consider these two PostgreSQL functions:
CREATE OR REPLACE FUNCTION f_1 (v1 INTEGER, v2 OUT INTEGER)
AS $$
BEGIN
v2 := v1;
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION f_2 (v1 INTEGER)
RETURNS TABLE(v2 INTEGER)
AS $$
BEGIN
v2 :=…

Lukas Eder
- 211,314
- 129
- 689
- 1,509
6
votes
4 answers
Code analysis comes back with suggestion about not using "out" parameters
I ran the VS 2008 code analysis tool against an object I created and received the following suggestion ...
Warning 147 CA1021 : Microsoft.Design
: Consider a design that does not
require that 'returnValue' be an out
parameter.
I find "out"…
user26901
5
votes
2 answers
C# - How can I pass a reference to a function that requires an out variable?
public class Foo
{
public void DoFoo()
{
int x;
var coll = TheFunc("bar", out x);
}
public Func> TheFunc { get; set; }
}
Error: "Argument 2 should not be passed with the 'out'…

michael
- 14,844
- 28
- 89
- 177
5
votes
1 answer
Why is the C# compiler claiming 'use of an unassigned variable' prior to 'yield return' and dynamic?
The compiler complains that resultingThing in the code below is being used before being assigned to.
private IEnumerable FindThings(dynamic spec)
{
if (spec == null)
yield break;
IThing resultingThing;
if (spec.Something…

Kit
- 20,354
- 4
- 60
- 103
5
votes
3 answers
Sybase IN and OUT parameters
I'm going nuts about how the Sybase JDBC driver handles stored procedures with mixed IN and OUT parameters. Check out this simple stored procedure:
CREATE OR REPLACE PROCEDURE p (IN i1 INT, OUT o1 INT, IN i2 INT, OUT o2 INT)
BEGIN
set o1 = i1;
…

Lukas Eder
- 211,314
- 129
- 689
- 1,509
5
votes
1 answer
H2: How to create a stored procedure with out parameters
I am attempting to create a stored procedure with out parameters in a JUnit test that is configured with Spring (non-boot). I understand from documentation and examples that I must alias a static method to respond to the stored procedure call.…

ds390s
- 587
- 1
- 6
- 19
4
votes
3 answers
C# Out parameter question: How does Out handle value types?
UPDATE So totally pulled a tool moment. I really meant by reference versus Out/Ref. Anything that says 'ref' I really meant by reference as in
SomeMethod(Object someObject)
Versus
SomeMethod(out someObject)
Sorry. Just don't want to change the…

Programmin Tool
- 6,507
- 11
- 50
- 68
4
votes
2 answers
Problem reading out parameter from stored procedure using c#
I just come across a strange problem where i cannot retrieve the sql stored procedure out parameter value. I struck with this problem for nearly 2 hours.
Code is very simple
using (var con = new SqlConnection(connectionString))
{
…

RameshVel
- 64,778
- 30
- 169
- 213
4
votes
1 answer
Out parameter is correctly assigned, but caller only sees a NULL. Clue?
I have this procedure that gets dropped/created as part of a T-SQL script - the idea is to insert a parent record, and output its ID to the caller so that I can insert children records using that ID.
if exists (select * from sys.procedures where…

Mathieu Guindon
- 69,817
- 8
- 107
- 235
4
votes
4 answers
C# - Using a function with "out" parameter within a Thread
I have the following function and I'd like to use it within a System.Threading.Thread :
private void tempFunction(int num, out string fullname, out string info)
{
// Doing a very long scenario.
// When finished, send results out!
…

Alaa Salah
- 885
- 1
- 13
- 23
4
votes
5 answers
PHP - MySQL gets value of out parameter from a stored procedure
I have called a MySQL stored procedure from PHP using mysqli. This has one out parameter.
$rs = $mysqli->query("CALL addNewUser($name,$age,@id)");
Here, @id is the out parameter. Next, I fire the following query to get the value of the out…

mtk
- 13,221
- 16
- 72
- 112
3
votes
3 answers
Should out params be set even if COM function fails?
When implementing a COM interface I always assign to the out parameters on success but should I do so also on error?
HRESULT CDemo::Div(/*[in]*/ LONG a, /*[in]*/LONG b, /*[out,retval]*/ LONG* pRet)
{
if (pRet == NULL)
return E_POINTER;
…

Motti
- 110,860
- 49
- 189
- 262
3
votes
4 answers
Most user friendly way of passing back two variables in Java?
I'm writing a library that contains some hash functions.
I want one of the functions to return the hash (byte[]) and the random salt (byte[]) that was generated for use with the hash. What would be the most user friendly, and intuitive, way of…

Petey B
- 11,439
- 25
- 81
- 101
3
votes
1 answer
Call MySQL procedure with OUT parameter
I want to get the id of the last inserted row from mysql, but i get somekind of Exception unhandled. The visual studio gives me this error :
MySql.Data.MySqlClient.MySqlException: 'OUT or INOUT argument 9 for routine test.pr_VendegFelvetele is not a…

silverstorm
- 53
- 6