From: | Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com> |
---|---|
To: | drunken <manuzi1(at)hotmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: C# reading result from a function |
Date: | 2015-07-06 05:44:48 |
Message-ID: | CAFjFpReYuVjxyx35y9cvm_S4-32H+DHfGCo=MyUF-vn4ExSvbQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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 <manuzi1(at)hotmail(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company
From | Date | Subject | |
---|---|---|---|
Next Message | Corey Huinker | 2015-07-06 06:49:14 | Re: dblink: add polymorphic functions. |
Previous Message | Michael Paquier | 2015-07-06 05:08:49 | Re: pg_archivecleanup, and backup filename to specify as an argument |