Error Devart.Data.PostgreSql.PgSqlException: 'operator does not exist: integer = text'

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
EvaRyabokon
Posts: 1
Joined: Tue 21 Apr 2020 07:29

Error Devart.Data.PostgreSql.PgSqlException: 'operator does not exist: integer = text'

Post by EvaRyabokon » Tue 21 Apr 2020 08:48

I tried to do a request but there is an exception: Devart.Data.PostgreSql.PgSqlException: 'operator does not exist: integer = text'. The table has correct fields with types.
It works with library Npgsql. What reason can be?
Thank you in advance for your support.

Code: Select all

static void Main(string[] args)
        {
            PgSqlParameter[] myParameters = new PgSqlParameter[]
            {
                new PgSqlParameter("@Param0", PgSqlType.Int) {Value = 0} ,
                new PgSqlParameter("@Param1", PgSqlType.Int) {Value = 10},
                new PgSqlParameter("@Param2", PgSqlType.Int) {Value = 20 }
            };
            PgSqlConnection pgConnection = new PgSqlConnection("..."); 
            
            var query = "SELECT * FROM public.V_BASES_W_4ALL AS vw WHERE ((ID = ANY (ARRAY[@Param0,@Param1,@Param2]))) limit 10000";


            PgSqlCommand pgCommand = new PgSqlCommand(query, pgConnection);
            for (int i = 0; i < myParameters.Length; i++)
            {
                pgCommand.Parameters.Add(myParameters[i]);
            }
            try
            {
                pgConnection.Open();

                pgCommand.ExecuteNonQuery();
            }
            finally
            {
                pgConnection.Close();
            }

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

Re: Error Devart.Data.PostgreSql.PgSqlException: 'operator does not exist: integer = text'

Post by Shalex » Thu 23 Apr 2020 20:06

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: Error Devart.Data.PostgreSql.PgSqlException: 'operator does not exist: integer = text'

Post by Shalex » Thu 07 May 2020 21:39

As designed.

Parameters could not be placed in any place of SQL statement. You should either pass the whole array as a parameter [1] or replace parameters with their values before command execution [2].

Or set UnpreparedExecute=true to get the behavior [2] automatically.

Post Reply