C# reading result from a function - Mailing list pgsql-hackers

From drunken
Subject C# reading result from a function
Date
Msg-id 1435997683850-5856560.post@n5.nabble.com
Whole thread Raw
Responses Re: C# reading result from a function
Re: C# reading result from a function
List pgsql-hackers
Hi guys, I have a problem with a sipmle function in postgresql. The func()
calculates two integers to a result and returns it. The result is in the DB,
but not in the Console Line in C#. So for example when i have par1 = 2 and
par2 = 5 I get an DB entry with 7 in the result row, but the ConsoleLine is
empty.

What is wrong here?

BEGIN  Result := par1 + par2;  insert into  t1 (par1, par2, res) values (par1, par2, Result);  RETURN Result;
END;$BODY$ LANGUAGE plpgsql VOLATILE COST 100;
ALTER FUNCTION test_func(integer, integer) OWNER TO "Test";


*****************************
c#:
.....

DbParameter giveBack = cmd.CreateParameter();               giveBack.DbType = DbType.Int32;
giveBack.ParameterName= "Result";               giveBack.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(giveBack);
               cmd.Parameters["par1"].Value = 2;               cmd.Parameters["par2"].Value = 11;
connection.Open();
               if (connection.State == System.Data.ConnectionState.Open) {
Console.WriteLine(cmd.Parameters["par1"].Value);                  Int32 result = cmd.ExecuteNonQuery();
 Console.WriteLine("Status: {0}: Result: {1}", result,
 
cmd.Parameters["Result"].Value);               }

Console.WriteLine for par1 returns 2. Console.Writline for Result returns
nothing.



--
View this message in context: http://postgresql.nabble.com/C-reading-result-from-a-function-tp5856560.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.



pgsql-hackers by date:

Previous
From: Marco Atzeri
Date:
Subject: postgresql-9.5alpha1 packaging
Next
From: chenhj
Date:
Subject: Re: PATCH:do not set Win32 server-side socket buffer size on windows 2012