Search found 3 matches

by Ralf Jansen
Wed 03 Aug 2011 07:27
Forum: dotConnect for PostgreSQL
Topic: PgSqlArray with PgSqlType.ByteA
Replies: 3
Views: 1648

MyProc just looks like this

Code: Select all

CREATE OR REPLACE FUNCTION fn_MyProc (cpositions bytea[])
  RETURNS void AS
$BODY$
BEGIN
   -- nop
END $BODY$
  LANGUAGE plpgsql VOLATILE STRICT
  COST 100;
The dotConnect Version is 5.30.196.0 and the PostgreSQL Server is 9.0.4 64bit.

But i have to say that i could not replicate the behaviour this morning. Possibly i had some interference with the same test using varchar instead of bytea. See the other thread where you said you could reproduce the error when using varchar.

Thanks
Ralf
by Ralf Jansen
Mon 01 Aug 2011 14:09
Forum: dotConnect for PostgreSQL
Topic: PgSqlArray with PgSqlType.Text or VarChar
Replies: 3
Views: 1505

PgSqlArray with PgSqlType.Text or VarChar

Hi,

next Problem with PgSqlArray. When sending a Text or varchar Array to a stored function im getting a
invalid byte sequence for encoding 'UTF8'
Exception when the Text contains German Umlauts or any other character with diacritics. I've tried adding a "SET CLIENT_ENCODING TO 'utf8'" (server encoding is utf8) to the command but that did not change anything.


Testcode

Code: Select all

object[] array = { "Hello", "World", "böse" };
using (PgSqlConnection con = new PgSqlConnection("aValidConnectionString"))
{
    con.Open();
    using (PgSqlTransaction tx = con.BeginTransaction())
    {
        using (PgSqlCommand command = new PgSqlCommand(@"fn_test", con))
        {
            command.CommandText = @"fn_test";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@cterms", PgSqlType.Array).Value =
                new PgSqlArray(array, PgSqlType.Text, 1, array.Length);
            command.ExecuteNonQuery();
        }
        tx.Commit();
    }
}
'fn_test' is just an empty stored function with a TEXT[] or VARCHAR[] parameter.


Ralf


Edit: Adding 'Unicode=true' to the connection string helped somewhat. I get a different Exception now :(.
Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
by Ralf Jansen
Fri 29 Jul 2011 15:43
Forum: dotConnect for PostgreSQL
Topic: PgSqlArray with PgSqlType.ByteA
Replies: 3
Views: 1648

PgSqlArray with PgSqlType.ByteA

Hi,

i'm trying to send an array of bytes[] as PgSqlType.ByteA to a stored function.

Code: Select all

byte[][] positions = new byte[10][];
// filling positions - 2.Dimension is of variable length

using (PgSqlCommand command = CreateCommand(tx))
{
    command.CommandType = CommandType.StoredProcedure;
    command.CommandText = @"MyProc";
    command.Parameters.Add("@param", PgSqlType.Array).Value = new PgSqlArray(positions, PgSqlType.ByteA, 1, positions.Length);
    command.ExecuteNonQuery();
}
I receive an
Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
Exception on ExecuteNonQuery(). I have no problem doing the same with Varchar, Int, BigInt etc. Did i hit a limitation of the Array Type or am i doing something wrong?

Ralf