Page 1 of 1

Dealing with composite types arguments

Posted: Fri 08 Dec 2017 07:11
by alex303
As I didn't get response from "request support" so duplicate my question here...

Code: Select all

create type "test_complex_rec" as (
                           num$ numeric,
                           str$ character varying
                           )

Code: Select all

create or replace function "test_complex_fun"(INOUT params "test_complex_rec") as
                  $BODY$
                  begin
                    params.num$ := params.num$ + 1;
                    params.str$ := 'some result';
                  end;
                  $BODY$ LANGUAGE plpgsql

Code: Select all

using (var q1 = new PgSqlCommand("test_complex_fun", connection) { CommandType = CommandType.StoredProcedure  })
            {
                var rowType = PgSqlRowType.GetRowType("test_complex_rec", connection);

                var complexValue = new PgSqlRow(rowType);
                complexValue[0] = 3;
                complexValue[1] = "lala";

                var compositeParam = new PgSqlParameter("params", complexValue)
                {
                    Direction = ParameterDirection.InputOutput
                };

                // add it manually
                //q1.Parameters.Add(compositeParam);

                // lets try describe from metadata
                q1.ParameterCheck = true;
                q1.Prepare();
                q1.Parameters[0].Value = complexValue;

                q1.ExecuteNonQuery(); // Anyway, we will get ArgumentOutOfRange
            }
Executing last line will raise ArgumentOutOfRange.
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in Devart.Data.dll
Additional information: The value for the output parameter 'params' is absent in the command execution result.
What is correct way to work with composite arguments? According to DBMonitor it will pass correct parameter (3, 'lala') to function, but how to retrieve 'out' value in c# code?

Re: Dealing with composite types arguments

Posted: Tue 12 Dec 2017 14:31
by Shalex
Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.

Re: Dealing with composite types arguments

Posted: Thu 11 Jan 2018 20:10
by Shalex
The bug with using composite type INOUT parameter is fixed: viewtopic.php?f=3&t=36447.