Dealing with composite types arguments

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
alex303
Posts: 1
Joined: Fri 08 Dec 2017 07:00

Dealing with composite types arguments

Post by alex303 » Fri 08 Dec 2017 07:11

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?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Dealing with composite types arguments

Post by Shalex » Tue 12 Dec 2017 14:31

Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Dealing with composite types arguments

Post by Shalex » Thu 11 Jan 2018 20:10

The bug with using composite type INOUT parameter is fixed: viewtopic.php?f=3&t=36447.

Post Reply