ORA01461 error inserting large polygon using OleDB
Hi, I'm getting an ORA 01461 error trying to insert a large polygon (WKB>4K or so). The code works for smaller ones. Any ideas what I can do to fix it?
-Database is Oracle 11g (11.2.0.1.0). Table has a primary key field and an SDO_GEOMETRY.
-Code is .NET C# using OleDb with the OraOLEDB.Oracle provider.
-Geometry is WKB being passed as a BLOB into the SDO_GEOMETRY constructor.
-Same large poly works OK as a query parameter, for example
'WHERE SDO_ANYINTERACT(Shape,SDO_GEOMETRY(TO_BLOB(?),4326))', but
fails on insert.
using (OleDbConnection conn = new OleDbConnection("Provider=OraOLEDB.Oracle;etc"))
{
conn.Open();
using (OleDbCommand cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.Text;
//SQL
cmd.CommandText = "INSERT INTO Polys (Oid,Shape) VALUES (?,SDO_GEOMETRY(TO_BLOB(?),4326))";
//Parameters
cmd.Parameters.AddWithValue("", 1234); // OleDb ignores parameter name
byte[] test = Shape.ToWKB(); // WKB should be fine; works if polygon isn't too big
OleDbParameter bp = cmd.CreateParameter();
bp.OleDbType = OleDbType.LongVarBinary;
bp.Size = test.Length;
bp.Value = test;
cmd.Parameters.Add(bp);
//Execute
cmd.ExecuteNonQuery(); // Throws exception if shape is large
}
}