Call Stored Procedure with inout parameters in c#

İlyas Derse <[email protected]>
Newsgroups gmane.comp.db.postgresql.general
Message-ID <CALcdmyTni2MGmyt4tVuUjH4bgLvQLKBuxaCoT8+-Th+Vqx_wXA@mail.gmail.com>
I tried with inout parameters but it did not work correctly.

here is my procedure :

CREATE OR REPLACE PROCEDURE public.testing ( INOUT x int )
LANGUAGE 'plpgsql'
AS $$
BEGIN
   x := x * 3;
END ;
$$;

my C# code:

public void myMethod2()
        {
            CRUD.con.Open();
            int a = 5;
            using (var cmd = new NpgsqlCommand("call public.testing();",
CRUD.con))
            {
                var objParam = new NpgsqlParameter("x",
NpgsqlDbType.Integer)
              { Direction = ParameterDirection.Output };
                objParam.Value = 5;
                cmd.Parameters.Add(objParam);
                cmd.ExecuteNonQuery();
                Console.WriteLine(objParam.Value);
            }
            CRUD.con.Dispose();
        }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.