ORA-21525 with ObjectType as Parameter and Unicode=true
Posted: Thu 12 Apr 2012 13:19
I get "ORA-21525 attribute number or (collection element at index) %s violated its constraints" when using an Object Type as parameter for a function when Unicode = true, if the length of the value is longer than 50% of the length of a varchar2-attribute of the object type.
Assume this scenario:
The type TAdress has been created (equal to the example in your documentation http://www.devart.com/dotconnect/oracle ... bject.html). Furthermore a Package with a function has been created:
Now create the OracleCommand to call the function, add the Parameter and execute it:
This is the ToOracleObject-Function:
With Unicode = false this will work for both cases.
With Unicode = true this will work for case 1, but will fail for case 2 and give ORA-21525 Exception. Although Country has a length of 30 (characters) and the value is just 16 characters long.
Is this probably a bug in NativeOracleObject?
I get this behaviour with 6.80.325. I just tested Functions of Packages. I did not test Procedures/Function outside of a package.
Regards,
Matthias
Assume this scenario:
The type TAdress has been created (equal to the example in your documentation http://www.devart.com/dotconnect/oracle ... bject.html). Furthermore a Package with a function has been created:
Code: Select all
FUNCTION countEmployees(adress IN TAdress) RETURN NUMBER;Code: Select all
Using cm As New Devart.Data.Oracle.OracleCommand
cm.CommandText = "BEGIN :RET := schema.package.countEmployees(:adress); END;"
..
Dim pAdress As New Devart.Data.Oracle.OracleParameter
pAdress.OracleDbType = Devart.Data.Oracle.OracleDbType.Object
pAdress.Direction = ParameterDirection.Input
pAdress.ObjectTypeName = "schema.TAdress"
pAdress.ParameterName = "adress"
pAdress.Value = Me.ToOracleObject(t.Connection)
cm.Parameters.Add(pAdress)
..
cm.ExecuteNonQuery()
End UsingCode: Select all
Public Function ToOracleObject(ByVal connection As FW.Data.Connection) As Devart.Data.Oracle.NativeOracleObject
Dim oracleObjectOci As Devart.Data.Oracle.NativeOracleObject
oracleObjectOci = New Devart.Data.Oracle.NativeOracleObject(OT_NAME, connection.OracleConnection)
'Case1:
'oracleObjectOci("Country") = "123456789012345"
'Case2:
'oracleObjectOci("Country") = "1234567890123456"
Return oracleObjectOci
End FunctionWith Unicode = true this will work for case 1, but will fail for case 2 and give ORA-21525 Exception. Although Country has a length of 30 (characters) and the value is just 16 characters long.
Is this probably a bug in NativeOracleObject?
I get this behaviour with 6.80.325. I just tested Functions of Packages. I did not test Procedures/Function outside of a package.
Regards,
Matthias