This mail is probably appropriate for some C# mailing list. I am not familiar with C#, but in the above code, I do not see where is test_func() being called?
On Sat, Jul 4, 2015 at 1:44 PM, drunken <manu...@hotmail.com> wrote: > 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. > > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers > -- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company